Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to upload photo to my website folder "upload"

but i can't write the path of that folder ???

how to write that bath ????


Server Error in '/' Application.

The SaveAs method is configured to require a rooted path, and the path '~\content\news\upload\55.jpg' is not rooted.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path '~\content\news\upload\55.jpg' is not rooted.

Source Error:


Line 14: conn.Close()
Line 15:
Line 16: FileUpload1.SaveAs("\\fs4-n01\stor3wc2dfw1\509429\509697\www.ittejahatcenter.com\web\content\news\upload\" & imgname & ".jpg")
Line 17: Else
Line 18: MsgBox("no iamge")
Posted

Are you sure that location exists?
Just use relavtive path declaration as:
C#
string saveDir = @"\Upload\"+Server.HtmlEncode(FileUpload1.FileName);
FileUpload1.SaveAs(saveDir);


otherwise try to use MapPath:
FileUpload1.SaveAs(Server.MapPath("~/Upload/") & FileUpload1.FileName)


http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx[^]

Good luck!
 
Share this answer
 
thank you so much:thumbsup:
thank you so much:thumbsup:
thank you so much:thumbsup:
 
Share this answer
 
Comments
E.F. Nijboer 12-Aug-10 10:01am    
Would be best to hit "Add Comment" right under the answer for comments next time instead of adding it as an 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