I have seen all the upload progress bar plugins, widgets, etc. – they all suck. They're either too bulky with too much useless code or they don't work.
What I want to know is where I can read up on how to display an easy upload progress indicator. Most browsers have a status progress bar on them below, but it isn't very professional to use just that when dealing with clients.
How does the browser do it? I want to know the internals of how the browser works with for indicating the status of something uploading so that maybe I can make something using PHP & jquery.
Thanks.
Since you want to use PHP, I'd start with the uploadprogress extension (PHP doesn't, by default, give you any data about until the upload is completed; this extension provides such server-side functionality). Note that it requires PHP 5.2+ and can be picky about configuration options. Also see its commentary and demo and troubleshooting hints). A short overview available in PHP documentation comments.
Using the extension, you can get some stats on the upload; then you can poll the server through AJAX and update some sort of progress bar.
To be a bit more specific:
(Oh, and btw, check PHP's upload_max_filesize and post_max_size settings, as both limit the maximum upload size)
There is no reliable method to get the progress of a file upload using JavaScript. Support for the XMLHttpRequest upload.onprogress
event is missing in many browsers, even with HTML5, you will inevitably need to turn to Flash, or another method of file upload.
After asking this question, I eventually settled on using plupload for my uploading needs.
Javascript/Ecmascript
cannot mess with native browser functionalitys (which uses C/C++
mostly along with OS APIs
which access TCP/UDP
sockets.
To display a progressbar with JS
you need serverfeedback. That can be accomplished by using a server polling
like COMET for instance.
But at this point, it's never that accurate like the browser buildin progressbar. It will change maybe with HTML5 WebSockets
.
To have an accurate result, you need a continuous connection. You can fake
and gild
the client-server request delay, but it's still there. I don't know exactly how Flash
handles this issues, but I guess it also does not have connection-oriented stream (Correct me if I'm wrong here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With