我有以下代码
HTML
d
JavaScript
(target, M)
问题
这看起来像一次一次将文件上传成块,每次2张。因此,如果我要上传8个文件,它将发出4个请求,每个请求包含2个文件。我想一次全部上传,有没有简单的方法可以做到这一点?这种方法会带来很多问题,因为用户可能会上载大量文档,并且当其中一半准备就绪时,他可以离开/刷新页面等,并且他将不得不搜索哪些文档已上传而哪些文档尚未上传。
答案 0 :(得分:0)
您需要根据所需的数量告诉放置区域在放置区域的选项中进行并行上传。
<script type="text/javascript">
$(document).ready(function() {
$('#documents_upload').dropzone({
url: "{{ route('documents.store') }}", // Set the url for your upload script location
paramName: "documents", // The name that will be used to transfer the file
maxFiles: 50,
maxFilesize: 4, // MB
addRemoveLinks: true,
acceptedFiles: "application/msword, application/vnd.ms-excel, application/pdf, image/*, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, image/*",
parallelUploads:10,
uploadMultiple: true,
headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}"
},
queuecomplete: function() {
// notify about successful upload
// window.location.replace("{{ route('client.documents.index') }}");
}
});
});
让我知道它是否有效!