我的拖放区有问题,
$(".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!");
});
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当文件上传失败时,它仍然显示预览图像,所以我需要在这些文件上传失败时自动删除该文件,我该怎么做?
dns*_*_nx 10
我想,如果我理解正确的话,你可以使用以下代码删除图像:
Dropzone.options.dropZone = {
...
, error: function(file, message, xhr) {
$(file.previewElement).remove();
},
...
}
Run Code Online (Sandbox Code Playgroud)
只需再次阅读文档即可。此代码来自文档:
myDropzone.on("error", function(file) {
myDropzone.removeFile(file);
});
Run Code Online (Sandbox Code Playgroud)
如果它适用于您的情况,请告诉我。
| 归档时间: |
|
| 查看次数: |
7242 次 |
| 最近记录: |