最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery multiple file upload limit number of files not working - Stack Overflow

programmeradmin3浏览0评论

Jquery multiple file upload with ajax.

option : {  
    limitMultiFileUploads : 3    
}

is not working for jquery file upload.

This is what i did :

$(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.

Jquery multiple file upload with ajax.

option : {  
    limitMultiFileUploads : 3    
}

is not working for jquery file upload.

This is what i did :

$(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.

Share Improve this question asked Jan 25, 2014 at 7:12 NishNish 3252 gold badges3 silver badges11 bronze badges 5
  • What is the observed behaviour? – Fractaliste Commented Jan 25, 2014 at 12:08
  • on submit files are uploading but files should not be uploaded when files limit is is crossed. – Nish Commented Jan 27, 2014 at 4:59
  • What do you want to do? A limit of 2 upload at the same time or 2 upload for every session? – Fractaliste Commented Jan 27, 2014 at 14:12
  • A limit of max 2 upload at the same time only. – Nish Commented Feb 19, 2014 at 15:31
  • Another why not working question: stackoverflow./questions/18551539/… – Ciro Santilli OurBigBook. Commented Nov 8, 2014 at 9:34
Add a ment  | 

2 Answers 2

Reset to default 2

You are actually looking for maxNumberOfFiles option.

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

My working code:

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

Get rid of the object with the name "option" and put the two settings at the same level as the rest of the options.

 $(function() {        
            $('#attachUpload').fileupload({            
                dataType: 'json',
                limitConcurrentUploads: 1,
                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) {
                }
    });
发布评论

评论列表(0)

  1. 暂无评论