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

Анд*_*нов 0 javascript jquery dropzone.js

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

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();
        }
    }
Run Code Online (Sandbox Code Playgroud)

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

小智 8

myDropzone.on('maxfilesreached', function() {
    myDropzone.removeEventListeners();
});
myDropzone.on('removedfile', function (file) {
    myDropzone.setupEventListeners();
});
Run Code Online (Sandbox Code Playgroud)

如果您的服务器中有文件,请不要忘记init _updateMaxFilesReachedClass.

myDropzone._updateMaxFilesReachedClass()
Run Code Online (Sandbox Code Playgroud)