我正在使用Dropzone.js在Laravel中上传多个图像。尽管图像上传没有任何错误,但请求为空。有什么解决办法吗?
HTML代码
<form class="form-horizontal" id="form" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="col-sm-2 control-label">ISSUE DATE / VOLUME NO</label>
<div class="col-sm-10"><input type="text" class="form-control" name="valume_no" value={{ old('valume_no') }}></div>
</div>
<div class="dropzone" id="my-dropzone">
<div class="dz-message">
<div class="col-xs-8">
<div class="message">
<p>Drop files here or Click to Upload</p>
</div>
</div>
</div>
<div class="fallback">
<input name="featured_file" type="file[]" multiple />
</div>
</div>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-2">
<button class="btn btn-primary" type="submit">Done</button>
</div>
</div>
</form>
防区配置
Dropzone.autoDiscover = false;
$(document).ready(function () {
$("#my-dropzone").dropzone({
url: '{{ url("/news/uploadimgsaddmode") }}',
headers: {
'x-csrf-token': "{{ csrf_token() }}",
},
method: 'post',
paramName: "file",
maxFiles: 100,
maxFileSize: 100,
acceptedFiles: ".jpeg,.jpg,.png",
uploadMultiple: true,
parallelUploads: 100,
previewTemplate: document.querySelector('#preview').innerHTML,
addRemoveLinks: true,
dictRemoveFile: 'Remove file',
dictFileTooBig: 'Image is larger than 16MB',
timeout: 10000,
success: function (file, response) {
console.log(response);
}
});
});
Laravel控制器
public function uploadimgsaddmode(Request $request){
return Response::json(['message' => $request], 200);
}
响应
{"message":[{}]}