Finish of Multiple file upload
Asked Answered
A

4

9

I have a question about the use of Blueimp jQuery-File-Upload plugin (https://github.com/blueimp/jQuery-File-Upload)

There is a callback function or an alternative method, to know when is finished an upload of multiple files? I do not want to know when is finished the upload of every single file, but when is finished the entire process (All Uploads Complited).

There is also the opportunity to know how many files have actually been loaded and how many they were requested?

Awry answered 26/9, 2013 at 10:29 Comment(1)
Possible duplicate of jQuery File Upload - how to recognise when all files have uploadedMaren
H
9

Please have a look at the "stop" callback option:

.bind('fileuploadstop', function (e) {/* ... */})

And If you want to track uploaded files try to use this:

$('#fileupload').bind('fileuploaddone', function (e, data) { }

Your collections data.files only contain 1 object each, hence you can track the count of files been uploaded.

Haga answered 26/9, 2013 at 10:33 Comment(0)
C
5

Yes, you can call it API to track the end of a multiple upload process:

var $fileInput = $('#fileupload');

$fileInput.on('fileuploaddone', function(e, data) {
    var activeUploads = $fileInput.fileupload('active');
    /*
     * activeUploads starts from the max number of files you are uploading to 1 when the last file has been uploaded.
     * All you have to do is doing a test on it value.
     */
    if(activeUploads == 1) {
        console.info("All uploads done");
        // Your stuff here
    }
}
Crypto answered 25/3, 2016 at 13:32 Comment(0)
E
1

Just on this guys, you can get the number of active uploads using the below:

var activeUploads = $('#fileuploadForm').fileupload('active');

See: https://github.com/blueimp/jQuery-File-Upload/wiki/API#retrieving-the-number-of-active-uploads

I was going to use a counter on always callback function to compare to this variable. But stop looks like it works perfectly.

Just want to clarify. If i have multiple singular file upload requests is stop() the best approach?

Equimolecular answered 17/4, 2014 at 4:14 Comment(1)
- To me, is stop will be called when all xhr are aborted or done. and fileupload('active') always returns 0. Not a good choice, though.Leblanc
K
0

On my case, I followed two answer's and didn't work.

So disable iPV6 make things work. It seems iPV6 throws a false positive to all uploads done.

Kerr answered 16/12, 2019 at 20:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.