gpt4 book ai didi

javascript - Dropzone.js 在触发事件后删除文件

转载 作者:数据小太阳 更新时间:2023-10-29 05:52:22 24 4
gpt4 key购买 nike

所以这是我的代码:

 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.
myDropzone.removeAllFiles();
console.log("a");

});

// 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.
});

}};

单击上传按钮后如何添加 removeAllfiles。谢谢

最佳答案

这应该有效:

Dropzone.options.myDropzone = {

autoProcessQueue: false,

init: function() {
var submitButton = document.querySelector("#submit-all")
myDropzone = this;

submitButton.addEventListener("click", function() {
myDropzone.processQueue();
});

// Execute when file uploads are complete
this.on("complete", function() {
// If all files have been uploaded
if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) {
var _this = this;
// Remove all files
_this.removeAllFiles();
}
});

}

};

通过使用 this.on("complete", function() {//要执行的代码 }); 您可以在文件上传后执行您的代码。在您的情况下,您可以删除所有文件。

关于javascript - Dropzone.js 在触发事件后删除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com