How to implement file upload progress bar on web?
Asked Answered
G

7

19

I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have?

Edit: I am using .Net but I don't mind if somebody shows me platform agnostic version.

Gauhati answered 8/9, 2008 at 12:24 Comment(0)
A
5

Here are a couple of versions of what you're looking for for some common JavaScript toolkits.

Arium answered 8/9, 2008 at 12:41 Comment(0)
F
14

If you are interested how all this generally works client-site, this is it:

All the solutions hook up the form via javascript and change the forms target to a newly created, invisible IFRAME. Then they are free to use AJAX to request some status about the file from the server.

The IFRAME trick is needed because all the scripts running in the window that is doing the upload will hang until the the request is completed at which time the file is fully uploaded.

Fitzgerald answered 8/9, 2008 at 14:28 Comment(2)
Is IFRAME really necessary? Can someone confirm this? I am confused.Clinometer
Yes, IFRAME is needed. You can't submit file uploads via AJAX (i.e. via the Javascript XMLHTTPRequest object) and just a normal form submit would prevent you from executing additional Javascript to poll the server for upload progress.Rivard
A
5

Here are a couple of versions of what you're looking for for some common JavaScript toolkits.

Arium answered 8/9, 2008 at 12:41 Comment(0)
T
3

ASP.NET File Upload with Real-Time Progress Bar

http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html

Trigonometry answered 8/9, 2008 at 12:41 Comment(1)
Is there an additional link? the one posted is no longer availableBui
R
2

I've tried various techniques and had most success with SWFUpload.

You create and interact with an SWFUpload object using Javascript, but uses a (hidden) Flash file for file selection, uploading and upload progress monitoring. You can specify a wide range of Javascript event handlers (uploadStarted, uploadProgress, uploadError etc.) that the Flash will call during the upload progress making it very flexible. It also implements a file queue, so it works well for single or multiple files.

Links:

Rivard answered 9/9, 2008 at 11:26 Comment(0)
S
1

Some good .NET-specific help for doing progress bars can be found in Dino Esposito's MSDN Magazine articles from last July and August:

Context-Sensitive Feedback with AJAX (July '07)
Canceling Server Tasks with ASP.NET AJAX (August '07)

Sphenoid answered 8/9, 2008 at 13:55 Comment(0)
T
0

A good example of doing this without using Ajax is given at CodeProject by Nilesh Thakkar.

Typescript answered 8/9, 2008 at 12:26 Comment(1)
It's a dummy progress bar. Does not show %percent uploaded. Might as well use the "uploading..." message as an overlay.Sashasashay
O
-3

jQuery UI Progressbar - http://jqueryui.com/demos/progressbar/

Obaza answered 28/8, 2009 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.