maxFileSize and acceptFileTypes in blueimp file upload plugin do not work. Why?

前端 未结 15 936
深忆病人
深忆病人 2020-12-07 08:34

I\'m using Blueimp jQuery file upload plugin for upload files.

I had no problem in uploading but the option maxFileSize and acceptFileTypes

15条回答
  •  渐次进展
    2020-12-07 08:48

    You should include jquery.fileupload-process.js and jquery.fileupload-validate.js to make it work.

    Then...

    $(this).fileupload({
        // ...
        processfail: function (e, data) {
            data.files.forEach(function(file){
                if (file.error) {
                    self.$errorMessage.html(file.error);
                    return false;
                }
            });
        },
    //...
    }
    

    processfail callback is launched after a validation fail.

提交回复
热议问题