Show Upload Progress

J

Jeff S

I'm enabling users to upload files to the server. I'd like to show them some
indication of percent complete. How can this be done?

Thanks!
 
A

Alvin Bruney [MVP]

One solution is to use a timer. Set a flag to show that the load has
started. Everytime the timer event fires examine the flag. As long as the
flag is set, display your message. When it's done, change the flag and stop
the timer.
 
J

Joe Fallon

This approach works to keep the user occupied while the file is uploaded.
But it does not show true progress as a percentage of the task completed.

ASP.Net blocks you from getting any data once the upload begins.
So you have to write code to intercept the request and handle it yourself.

In fact, to get a true percentage is extremely difficult. I read a thread on
the topic that lasted almost 2 years. Some guys posted 90% of the code
required to do it and then hired themselves out to 3rd party companies and
built it for them. To my knowledge there is no free public domain code for
how to do this.
--
Joe Fallon




Alvin Bruney said:
One solution is to use a timer. Set a flag to show that the load has
started. Everytime the timer event fires examine the flag. As long as the
flag is set, display your message. When it's done, change the flag and stop
the timer.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
Jeff S said:
I'm enabling users to upload files to the server. I'd like to show them some
indication of percent complete. How can this be done?

Thanks!
 
J

Jeff S

Sounds like this will do for my situation. I understand it's not a true
measure of progress, but in my situation I'm most interested in letting the
user know that the upload is not hung and to please continue waiting. I'd
hate for them to restart their session or repeatedly click the "upload now"
button.

I'm using the HtmlInputFile control, and I'm a bit sketchy on *how* it works
(although I do have it all working). I suppose it works with the browser to
enable navigation of the client machine to find the file to be uploaded, but
beyond that I'm not sure what happens in order to copy the file from the
client to the server. I have a separate button that initiates a postback:
does the uploaded file come in as part of the POST (postback) data? If not,
how doess it come in? Where and when would I initiate the timer? and where
would I set the flag? I could figure it all out except that I'm just not
clear on when/where in the code I'd get a chance to start the timer and set
the flag prior to the upload actually beginning.

Thanks.



Alvin Bruney said:
One solution is to use a timer. Set a flag to show that the load has
started. Everytime the timer event fires examine the flag. As long as the
flag is set, display your message. When it's done, change the flag and stop
the timer.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
Jeff S said:
I'm enabling users to upload files to the server. I'd like to show them some
indication of percent complete. How can this be done?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,174
Latest member
BlissKetoACV
Top