Javascript 取消单个文件的上载停止所有文件的上载-Dropzonejs
当我开始使用以下代码上载多个文件时,addRemoveLinks:true提供取消上载的选项。当我取消上传的任何一个文件时,它会停止上传所有文件。它还显示总进度百分比为100% 谁能帮我理解我做错了什么?我想在取消上传一个单一的文件不应该影响其他文件的上传。 我该怎么做Javascript 取消单个文件的上载停止所有文件的上载-Dropzonejs,javascript,jquery,asp.net-mvc,file-upload,dropzone.js,Javascript,Jquery,Asp.net Mvc,File Upload,Dropzone.js,当我开始使用以下代码上载多个文件时,addRemoveLinks:true提供取消上载的选项。当我取消上传的任何一个文件时,它会停止上传所有文件。它还显示总进度百分比为100% 谁能帮我理解我做错了什么?我想在取消上传一个单一的文件不应该影响其他文件的上传。 我该怎么做 Dropzone.options.myAwesomeDropzone = { autoProcessQueue: false, uploadMultiple: true, parallelUpload
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
maxFilesize: 1000,
addRemoveLinks: true,
// The setting up of the dropzone
init: function () {
var myDropzone = this;
this.element.querySelector("button[type=submit]").addEventListener("click", function (e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
var atLeastOneIsChecked = $('input:checkbox').is(':checked');
if(atLeastOneIsChecked)
myDropzone.processQueue();
else
alert("Please select a company!");
});
myDropzone.on("totaluploadprogress", function (progress) {
// Update progress bar with the value in the variable "progress", which
// is the % total upload progress from 0 to 100
$("#prog").html(progress);
});
myDropzone.on("drop", function (event) {
// Update progress bar with the value in the variable "progress", which
// is the % total upload progress from 0 to 100
$("#prog").html("0");
});
}
}
我通过修改源代码解决了这个问题
Dropzone.prototype.cancelUpload = function (file) {
var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
if (file.status === Dropzone.UPLOADING) {
this.emit("canceled", file);
} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
file.status = Dropzone.CANCELED;
this.emit("canceled", file);
if (this.options.uploadMultiple) {
this.emit("canceledmultiple", [file]);
}
}
if (this.options.autoProcessQueue) {
return this.processQueue();
}
};