HTTP upload progress bars are rather obfuscated- they typically involve a process running on the server keeping track of the size of the tempfile that the HTTP server is writing to, then on the client side an AJAX call is made every couple seconds to the server during the upload to ask for the progress of the upload.
This is pretty ridiculous. Making million of AJAX requests (which probably slow down your upload) just to poll the server on this trivial fact? Your browser knows how much data you've sent - the best solution would be to have this information stored in the DOM. As far as I can tell, this is not happening.
Xupload (Discontinued product) is a beautiful hack to do this without AJAX. When you start your download it streams an HTML back back to you slowly. The first part of the HTML is normal, with elements defining the progress bar, javascript, etc., this comes all at once. Then comes information about your upload in progress incrementally as javascript calls:
<script>SP(4,0,0,0,0);</script> <script>SP(8,0,0,0,0);</script> <script>SP(8,1,8,0,2);</script> <script>SP(12,1,12,0,1);</script>
These javascript calls update the progress bar defined above. (SP($size,$time,$speed,$files_uploaded,$time_left)) Basically: you're loading a single page and as it loads the progress bar moves.
Can we do this in Rails? I've been experimenting with both Sean Treadway's UploadProgress and mongrel_upload_progress but have had no luck yet.
Ry