In jQuery file uploader (http://blueimp.github.io/jQuery-File-Upload/), when I start uploading some files, I want to show a line saying "Uploaded x of y". x is the number of files successfully uploaded, and y is the number of files uploading/queued. How do I get those two numbers? I have looked at the options but I didn't find anything I can use.
If the page is refreshed during or after upload is finished, I also want to show a message called "x files uploaded". So how can I get that number? It would also be good to know how to count number of files failed during upload.
Thanks for your help.
Based on API documentation you can use
"Callback Options"
to bind event during your upload.The one you are looking for is :
And also :
Just keep some variable to increment and manage your display.
Also be careful not forgotting error handling (with ´ process fail´ event) if an error occurs to display proper interface.
To know about how many files you are sending, just use
add events
to keep track of your variable.There is some function you can call to have those values but I would not recommend them since event binding has been build specifically to keep your code synchronized at any time.
About page refresh
You need to use a
sessionStorage
to keep values when refreshing a page. The easiest way is to update this value everytime your number_of_files change. (see document on MDN)You just need on load (or initialization of your upload plugin) to get this value and set initial value of your variable ... this way it will keep track of previous session.
Suggestion of code
You just need to have all case in your code like deletion, modification and other ... to make sure your value is always up to date. But jQuery-File-Upload is not suppose to be in charge of your view, as part of MVC pattern it only do one thing which is uploading and giving you all tools to work with that