在我的控制器中,当我尝试dd($request->file('file'));
时返回null ...请解决任何问题!
更多信息,我使用提交按钮autoProcessQueue: false
仅上传了一张没有Ajax请求的图片,因为我有其他需要验证的输入。当我将自动进程转为true时,只是为了测试上传工作正常,但文件请求仍然为空。
观点:
<form role="form" action="{{ route('user::products::store') }}" method="POST" enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="image {{ $errors->has('thumbnail') ? 'has-error' : '' }}">
<div id="droparea">
<div class="message" data-dz-message>
<span class="glyphicon glyphicon-cloud-upload"></span>
<p>Click or drag image here</p>
</div>
<div class="preview">
<div class="template">
<div class="thumb">
<img data-dz-thumbnail />
<span data-dz-remove class="glyphicon glyphicon-remove remove"></span>
</div>
</div>
</div>
</div>
</div>
</form>
Dropzone.js配置
<script>
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(document.body,
{
url: "/u/products/add",
autoProcessQueue: false,
previewTemplate: previewTemplate,
previewsContainer: ".preview",
clickable: "#droparea",
paramName : "file",
acceptedFiles: "image/.jpeg,.jpg,.png",
maxFilesize: 2,
maxFiles: 1,
thumbnailWidth: 150,
thumbnailHeight: 150,
headers: {
'X-CSRF-Token': $('input[name="_token"]').val()
}
});
</script>
答案 0 :(得分:0)
尝试添加输入字段:
<input type="file" name="file" />