jquery多个文件上传限制文件数不起作用 [英] jquery multiple file upload limit number of files not working

查看:232
本文介绍了jquery多个文件上传限制文件数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ajax Jquery多个文件上传。

Jquery multiple file upload with ajax.

option : {  
    limitMultiFileUploads : 3    
}

不能用于jquery文件上传。

is not working for jquery file upload.

这就是我所做的:

$(function() {        
        $('#attachUpload').fileupload({            
            dataType: 'json',
            limitConcurrentUploads: 1,
            option:
                {
                    maxFileSize: 40000,
                    maxNumberOfFiles: 2
                },
            start: function(e) {
                $('.btn-sent').unbind('click'); // important - remove all event handlers
            },
            done: function(e, data) {
                var data = $.parseJSON(data._response.jqXHR.responseText);
                doneflag--;
                if (doneflag == 0) {                                              
                        $('#frmCompose').submit();                       
                }
            },
            submit: function(e, data) {                
                data.formData = setFormData();                
            },
            add: function(e, data) {
            }
});

但文件大小限制和文件数限制不起作用,任何人都可以帮忙。

but filesize limit and number of files limit not working can anyone help please.

推荐答案

您实际上在寻找 maxNumberOfFiles 选项。

有关文档的更多详细信息: https://github.com/ blueimp / jQuery-File-Upload / wiki / Options

More details on the doc: https://github.com/blueimp/jQuery-File-Upload/wiki/Options

我的工作代码:

$('#fileupload').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: '../uploaderDemo/server/php/',
        maxNumberOfFiles: 1,
        acceptFileTypes: /(\.|\/)(mp3|wav)$/i
    });

这篇关于jquery多个文件上传限制文件数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆