user3129040 user3129040 - 4 months ago 17
jQuery Question

Start Upload all in jquery file upload blueimp

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

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();
            });
        }
Comments