Click here to Skip to main content
15,913,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Picture uploaded sucessfully. after the page load the text in file browse text box cleared this is the real problem guide me to fix

This is my code

C#
try
{
if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".bmp" || fileExt == ".jpeg" || fileExt == ".png")
                   {
           file.SaveAs(Server.MapPath("~/Images/") + fileName);
                       if (i == 0)
                       {
                           Image1.ImageUrl = "~/Images/" + fileName;
                           string filePath = Server.MapPath("~/Images/").ToString();
                           file.SaveAs(Server.MapPath("~/Images/") + fileName);
                       }
                   }
               }
               catch (Exception ex)
               {
                   throw ex;
               }
Posted
Comments
Rahul Rajat Singh 5-May-12 6:36am    
Once the image is uploaded why do you need that. what if the user accidentally hit upload again?
bbirajdar 5-May-12 12:20pm    
Thats the behaviour of file upload control and it is controlled by browser. You dont have control over it..

1 solution

Dear Tamimun,

first of all, it is not a problem.once you upload image and it is saved to your diectory, there is no need to keep that text in your control otherwise when you click upload again it will be uploaded again and again.There is no solution for that.

Yes one alternative is there.

You can use agax contol toolkit.
and use Asyc file upload control from toolkit..

use this link for more ....

http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900