Click here to Skip to main content
15,662,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
friends i am using uploadfile control to save file on server the which is i am using given below but i am not able to see file on server the folder is still blank can you guide me ??
C#
if (FileUploader.HasFile)
    try
    {
        FileUploader.SaveAs(Server.MapPath("confirm//") +
             FileUploader.FileName);
        Label1.Text = "File name: " +
             FileUploader.PostedFile.FileName + "<br>" +
             FileUploader.PostedFile.ContentLength + " kb<br>" +
             "<br><b>Uploaded Successfully";
    }
    catch (Exception ex)
    {
        Label1.Text = "ERROR: " + ex.Message.ToString();
        Label1.Visible = true;
    }
else
{
    Label1.Text = "You have not specified a file.";
    Label1.Visible = true;
}


[edit]HTML encoded to get rid of spurious closing tags - OriginalGriff[/edit]
Posted
Updated 28-Jul-11 22:33pm
v2
Comments
Uday P.Singh 29-Jul-11 4:33am    
are you getting any error message? if yes then please post it.
RaisKazi 29-Jul-11 4:42am    
Your code seems to be Ok.

Try giving Full Rights to "confirm" folder to user "network_services". Hopefully it should then work.

Even if doesn't work then let us know exact error.

Check your path: Server.MapPath returns a path based on the current executing file location if a qualified path is not given. You may want to try "~/confirm/" instead of "confirm//"
 
Share this answer
 
Comments
guptaadeepak 29-Jul-11 7:20am    
dear griff code is right i am provide permission in IIS and now is working fine thanks for reply
You can use this code for file name.
string filename = Path.GetFileName(this.upload.FileName);


and
also use for server upload
C#
upload.SaveAs(Server.MapPath("~/IMEINO/") + filename);


u try it ....
all the best.
 
Share this answer
 
Comments
guptaadeepak 29-Jul-11 7:21am    
thanks bro problem is sortout

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