注意:我厌倦了所有与此主题相关的问题和答案。
我想删除 dropzone 中的当前上传文件。我设置了 alert('i remove current file');
我设置了最大大小,任何人都可以上传超过 siz 的文件,然后在此时删除.
我的代码 Here
最佳答案
要从 dropzone 中删除文件,您只需调用 removeFile()
方法,最简单的方法是使用闭包。
var myDropzone = new Dropzone("#mydropzone", {
url: "/file/post",
acceptedFiles: accept,
maxFilesize: 0.5,
uploadMultiple: false,
createImageThumbnails: false,
addRemoveLinks: true,
maxFiles: 3,
maxfilesexceeded: function(file) {
this.removeAllFiles();
this.addFile(file);
},
init: function() {
var drop = this; // Closure
this.on('error', function(file, errorMessage) {
//alert(maxFilesize);
//this.removeAllFiles();
if (errorMessage.indexOf('Error 404') !== -1) {
var errorDisplay = document.querySelectorAll('[data-dz-errormessage]');
errorDisplay[errorDisplay.length - 1].innerHTML = 'Error 404: The upload page was not found on the server';
}
if (errorMessage.indexOf('File is too big') !== -1) {
alert('i remove current file');
// i remove current file
drop.removeFile(file);
}
});
}
});
关于jquery - 如何删除dropzone中的当前上传文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39830629/