--- Dropzone JS ---
如何通过单个API调用删除所有文件?
说,
我上传了4张图片;在弹出的关闭/取消事件上,我触发了removeAllFiles(true)
,该事件将从Dropzone区域删除文件,但会调用4个API调用。
如何获取文件数组并立即删除?
_.extend(vm.dzOptions, {
"init" : function () {
let _this = this;
// Setup the observer for the button.
document.querySelector("button.attach-cancel-btn").addEventListener("click", function () {
// If you want to cancel uploads as well, you
// could also call _this.removeAllFiles(true);
_this.removeAllFiles(true);
});
},
"sendingmultiple": function (files, xhr, formData) {
formData.append("destination", dzOptionsData.destination);
formData.append("attachmentCount", files.length);
},
"removedfile" : function (file) {
if (file.status !== "canceled") {
$http.post("/delete-file", {paths: file.absolutePath}).then(
(res) => {
res = res.data;
if (res.code == "OK") {
file.previewElement.remove();
Notification.success({"message": res.message, replaceMessage: true});
}
else {
Notification.error({"message": res.message, replaceMessage: true});
}
},
(err) => {
Notification.error({"message": err.message, replaceMessage: true});
}
);
}
}
});
应该有一个称为removemultiple
的功能,就像其他多个选项一样。
谢谢。