Performing HTML5 File Upload - Client Side Only

I noticed that the new XMLHttpRequest object supports the onprogress event in firefox. Is it possible to use part of the new HTML5 api file to get a download progress bar without any changes on the server side?

+7
javascript html5 upload file-upload
source share
2 answers

I believe in principle yes, although I have not tried it yet.

What will be the problem is that XMLHttpRequest#send() accepts a Unicode string and encodes it as UTF-8. This prevents you from sending clean binary files, and most binary files, such as images, will not be valid UTF-8 sequences.

Most likely, you will use the fact that the FileAPI specification calls a “binary string” (bytes are treated as ISO-8859-1, so each charCodeAt corresponds to a byte), encoded in UTF-8. This is about 50% more than just downloading a file. Is it worth a slower download to get a progress report?

(God, if browsers had a better interface to show how the download is going, none of the endless jokes / Flash / Java / ActiveX would be necessary. Come on, sellers of browsers, this is a good big info pop-up window with a progress indicator, which too much to ask for?)

+2
source share

Yes, theoretically, although I will have to question the accuracy, because the speed of the Internet usually fluctuates (moreover, if you are not connected). Most likely, he will jump a lot.

And again, what is an accurate indicator of progress? I would like to see it on Windows before I see it online!

0
source share

All Articles