Finish of Multiple file upload

2020-04-03 10:26发布

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?

4条回答
成全新的幸福
2楼-- · 2020-04-03 10:34

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
    }
}
查看更多
\"骚年 ilove
3楼-- · 2020-04-03 10:40

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?

查看更多
够拽才男人
4楼-- · 2020-04-03 10:51

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.

查看更多
爷的心禁止访问
5楼-- · 2020-04-03 10:53

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.

查看更多
登录 后发表回答