Dropzone autoProcessQueue:假不起作用 [英] Dropzone autoProcessQueue: false not working
本文介绍了Dropzone autoProcessQueue:假不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试在单击按钮时上传文件.
I'm trying to upload files on button click.
我已经关注了很多教程/问题,例如, 通过按钮上传所有文件, Dropzone.js在laravel 5.4中发布请求.但是没有成功.
I have followed so much tutorials/questions like, Upload all files with a button, Dropzone.js post request in laravel 5.4. But didn't get success.
这是我的查看文件代码,
This is my view file code,
<form action="{{ url('admin/candidate/file-upload') }}" method="post" class="dropzone" id="my-dropzone">
{{ csrf_field() }}
<div class="dz-message">
<h3>Drop images here or click to upload.</h3>
</div>
</form>
这是我的JS文件代码(在文档就绪块中),
And this is my JS file code (in document ready block),
//DropZone - Drag and drop file upload
Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
init: function () {
var submitButton = document.querySelector("#submit-all")
myDropzone = this; // closure
submitButton.addEventListener("click", function () {
myDropzone.processQueue(); // Tell Dropzone to process all queued files.
});
// You might want to show the submit button only when
// files are dropped here:
this.on("addedfile", function () {
// Show submit button here and/or inform user to click it.
});
}
};
但是我认为我的这个js文件块没有执行.应该是什么问题?
But I think my this js file block is not executing. What should be the problem?
推荐答案
我遇到了同样的情况,并发现了以下代码:
I fall at the same situation and found out that code:
Dropzone.options.myDropzone = { .. }
没什么用.相反,我使用:
does nothink useful. Instead I use:
Dropzone.forElement(".dropzone").options.autoProcessQueue = false;
然后,当我需要排队时:
and after, when i need to queue i do:
Dropzone.forElement(".dropzone").processQueue();
这篇关于Dropzone autoProcessQueue:假不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文