Start Upload all in jquery file upload blueimp

前端 未结 3 1064
走了就别回头了
走了就别回头了 2021-01-02 02:14

I use jQuery file upload blueimp and have read

$(function () {
    $(\'#fileupload\').fileupload({
        dataType: \'json\',
        done: function (e, da         


        
相关标签:
3条回答
  • 2021-01-02 02:51

    For upload concurrently all file you have selected, you can add the option autoUpload: true, like this:

    $('#fileupload').fileupload({
        url: 'url_path',
        autoUpload: true
    })
    

    Reference: https://github.com/blueimp/jQuery-File-Upload/wiki/Options

    0 讨论(0)
  • 2021-01-02 03:00

    your problem is that you unbind the click event on every file. you should do it on done:

    done: function (e, data) {
                $("#uploadBtn").off('click')
                $.each(data.result, function (index, file) {
                    $('<p/>').text(file.name).appendTo(document.body);
                });
            },
    add: function (e, data) {
                $("#uploadBtn").on('click',function () {
                    data.submit();
                });
            }
    
    0 讨论(0)
  • 2021-01-02 03:03
    var pendingList: [];
    
    var sendAll: function () {
            pendingList.forEach(function (data) { data.submit(); });
            pendingList = [];
        };
    
    $('#fileupload').fileupload({
        url: 'url_path',
        autoUpload: false,
    
        add: function (e, data) {
                pendingList.push(data);
            },
    
    
    });
    
    <button onclick="sendAll()">Start Upload All</button>
    
    0 讨论(0)
提交回复
热议问题