2

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:

  1. 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?

  2. What is meant by the line, parseInt(data.loaded / data.total * 100, 10);

The original link to Jquery File Upload

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

You should use progressall callback, but data.total could be inaccurate.

See here for a solution:

jquery fileupload inaccurare progressbar

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.