I am using Dropzone to upload images using Laravel 5. After Dropzone makes the put call to my URL I get the following error:
TokenMismatchException in VerifyCsrfToken.php line 67:
However, when I look at the payload for the request the token is present:
------WebKitFormBoundary91A7BYrMsDcGTEvx Content-Disposition: form-data; name="_method"
PUT ------WebKitFormBoundary91A7BYrMsDcGTEvx Content-Disposition: form-data; name="_token"
j3NbjibYF7k8g2w1P0enw6YVfDrDvCGKFMCFt4NX ------WebKitFormBoundary91A7BYrMsDcGTEvx Content-Disposition: form-data; name="title"
Here is my JS:
Dropzone.options.realDropzone = {
url: '/user/manage/10',
method: 'PUT',
paramName: 'file',
uploadMultiple: false,
parallelUploads: 100,
previewsContainer: '#dropzonePreview',
addRemoveLinks: true,
maxFiles: 10,
autoProcessQueue: false,
init: function () {
var dropZone = this;
this.element.querySelector("#save").addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
console.log("clicked submit");
dropZone.processQueue();
});
},
};
My form:
{!! Form::model($asset, ['method' => 'PUT', 'class' => 'dropzone', 'id' => 'real-dropzone', 'action' => ['UserManagementController@update', $asset->id], 'file' => true]) !!}
My controller:
public function update(Request $request, $id)
{
return dd(FileRequest::file('file'));
}