我的 dropzone 有问题,
$(".js-example-basic-multiple").select2();
Dropzone.options.dropZone = {
//options here
maxFilesize: 2,
addRemoveLinks: true,
removedfile: function(file) {
var name = file.name;
$.ajax({
type: 'POST',
url: host+'upload/unfile',
data: "id="+name,
dataType: 'html'
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
//console.log();
},
init: function() {
this.on("maxfilesexceeded", function(file){
alert("No more files please!");
});
}
}
我的问题是,当文件上传失败时,它仍然显示预览图像,所以我需要在这些文件上传失败时自动删除该文件,我该怎么做?
最佳答案
我想,如果我没理解错的话,您可以使用以下代码删除图片:
Dropzone.options.dropZone = {
...
, error: function(file, message, xhr) {
$(file.previewElement).remove();
},
...
}
只需再次阅读文档。 此代码来自文档:
myDropzone.on("error", function(file) {
myDropzone.removeFile(file);
});
如果它适用于您的情况,请告诉我。
关于Dropzone.js - 如果上传失败则删除预览文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44535420/