Search code examples
javascriptfine-uploader

FineUploader client event after all uploads are done


I implemented FineUploader and I would like to hook up my client script to an event after all files are uploaded. Is that possible?

My implementation follows. Just want to know if that's right direction.

    function init() {
    var uploader = new qq.FineUploader({
        element: document.getElementById('button-selectfiles'),
        request: {
            endpoint: '/Up/UploadFile'
        },

        callbacks: {
            onStatusChange: onFileUploadStatusChange
        }
    });
};

var uploads = 0;
function onFileUploadStatusChange(id, oldStatus, newStatus) {
    console.log(newStatus);

    if (newStatus === 'submitting') {
        uploads++;
    }

    if (newStatus === 'upload successful' || newStatus === 'upload failed') {
        uploads--;
    }

    if (uploads === 0) {

        console.log('done');
    }
}

Solution

  • onComplete - used for single upload file, if you are using a multiple files upload just use onAllComplete:

    callbacks: {
        onAllComplete: function() {
            alert('done')
        }
    }