Dropzone - 自动删除未接受文件的缩略图
Dropzone - auto remove thumbnail of non acceptedFiles
我应用了以下设置:
acceptedFiles: "image/jpeg, image/jpg, image/png, image/gif",
其他文件也不例外,但缩略图不会自动删除,我也想删除缩略图。
目前,dropzone 对未接受的文件给出以下错误:You can't upload files of this type.
我不想显示该消息,只需从拖放区中删除该缩略图即可。
谁能告诉我,我怎样才能达到同样的效果?
试试这个:
init: function() {
this.on("addedfile", function (file) {
var _this = this;
if ($.inArray(file.type, ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']) == -1) {
_this.removeFile(file);
}
});
}
我应用了以下设置:
acceptedFiles: "image/jpeg, image/jpg, image/png, image/gif",
其他文件也不例外,但缩略图不会自动删除,我也想删除缩略图。
目前,dropzone 对未接受的文件给出以下错误:You can't upload files of this type.
我不想显示该消息,只需从拖放区中删除该缩略图即可。
谁能告诉我,我怎样才能达到同样的效果?
试试这个:
init: function() {
this.on("addedfile", function (file) {
var _this = this;
if ($.inArray(file.type, ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']) == -1) {
_this.removeFile(file);
}
});
}