gpt4 book ai didi

javascript - 如何在选择文件后禁用 Dropzone.js?

转载 作者:行者123 更新时间:2023-11-28 11:33:41 25 4
gpt4 key购买 nike

在我的拖放区中,我首先选择要保存的文件,然后单击“保存”按钮进行保存。所以,我的问题是:选择文件后如何禁用拖放区?我试过这样的

accept: function (file, done) {
if (file.type != "image/jpeg" && file.type != "image/png" && file.type != "image/gif") {
$('.file-row').find('img').attr('src', '/../Content/images/decline.png');
$('.file-row').find('img').attr('class', 'error-img');
done("Error! Files of this type are not accepted");
}
else {
$('.file-row').find('img').attr('src', '/../Content/images/accept.png');
$('.file-row').find('img').attr('class', 'accept-img');
done();
logoDropzone.disable();
}
}

但是这段代码不允许我上传文件,会弹出“上传已取消”错误。我能做什么?

最佳答案

myDropzone.on('maxfilesreached', function() {
myDropzone.removeEventListeners();
});
myDropzone.on('removedfile', function (file) {
myDropzone.setupEventListeners();
});

如果您有来自服务器的文件,请不要忘记 init _updateMaxFilesReachedClass。

myDropzone._updateMaxFilesReachedClass()

关于javascript - 如何在选择文件后禁用 Dropzone.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31401693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com