|
-
Sep 18th, 2012, 02:45 PM
#1
Thread Starter
Fanatic Member
Keeping the client informed
I have a page where users can add attachments to an email. The code to save the files to the server is below. When I start uploading I will write to the page (for example) 'Uploading File 1 of 4'. When the first file has been saved, I want to refresh the text the user is viewing to say ... 'File 1 uploaded, Uploading File 2 of 4' etc. I don't need to show a progress bar or anything fancy ... but how can you keep the browser updated so the user can see how many files have been uploaded etc.
Code:
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(path + ReturnValue.ToString() + "\\" + Path.GetFileName(hpf.FileName));
//****************** This is where I need to update some text in the browser as each file is uploaded ***********************
}
}
-
Sep 25th, 2012, 12:30 AM
#2
Re: Keeping the client informed
The basic Asp.net upload file control does not support this kind of progress. What you can do either use the Ajax or Jquery for this progress effect.
Here are the Examples.
1. Example 1
2. Example 2
Please mark you thread resolved using the Thread Tools as shown
-
Sep 25th, 2012, 03:14 AM
#3
Thread Starter
Fanatic Member
Re: Keeping the client informed
 Originally Posted by danasegarane
The basic Asp.net upload file control does not support this kind of progress. What you can do either use the Ajax or Jquery for this progress effect.
Here are the Examples.
1. Example 1
2. Example 2
Hi and thanks for your response.
In the first example - I don't understand. Where does the interaction between the server and the client take place. The server side code in the .ashx file is just the usual saving of a HttpPostedFile.
Where/how does the interaction take place between the .ashx code and the jquery code on the client?
Do you think I could use the same functionality if, instead of saving the files within the .ashx file, I stream them to a web service?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|