Reputation: 9396
I have difficulties in understanding the progress-bar
functionality of the jquery-file-upload
.
What is meant by the following snippet?
.on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('.progress .progress-bar').css('width', progress + '%');
});
The questions are:
How is the progress calculated? Actually, the file name is passed to my upload
controller and I save it immediately. Then how is this progress reported or by whom?
What is meant by the line, parseInt(data.loaded / data.total * 100, 10);
The original link to Jquery File Upload
Upvotes: 2
Views: 1694
Reputation: 4058
You should use progressall
callback, but data.total
could be inaccurate.
See here for a solution:
jquery fileupload inaccurare progressbar
Upvotes: 0
Reputation: 144
I think the script calculates the number of bytes which have been transported to from the client-side to the server.
The event fileupload progressall combines the information about all loading files and displays it at two variables data.loaded
, and data.total
.
data.loaded
- how many bytes were loaded
data.total
- total size transferring data to server
parseInt(data.loaded / data.total * 100, 10);
//will return the percent of uploaded data
About function parseInt
Upvotes: 1