Start Upload all in jquery file upload blueimp

user3129040 picture user3129040 · Dec 23, 2013 · Viewed 11.6k times · Source

I use jQuery file upload blueimp and have read

$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
            });
        },
        add:function (e, data) {
            $("#uploadBtn").off('click').on('click',function () {
                data.submit();
            });
        }
    });
});

but this uploads a single file, I want to upload all files that have been selected.

Answer

Rahmat Anjirabi picture Rahmat Anjirabi · May 27, 2015
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>