Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone know please reply...

i want to store image in a particular folder when i upload image in server...
i tried following codes but all are returns error like can't find out path....


my code:

1.
C#
string savepath = Server.MapPath("../userside/clogo/" + fileName);
               uploadlogo.SaveAs(savepath);


2.
C#
string savepath = Server.MapPath("./userside/clogo/" + fileName);
               uploadlogo.SaveAs(savepath);


3.
C#
string savepath = Server.MapPath("~/userside/clogo/" + fileName);
               uploadlogo.SaveAs(savepath);

4.
C#
string savepath = Server.MapPath("userside/clogo/" + fileName);
               uploadlogo.SaveAs(savepath);
Posted

Hi, use below code

C#
string FileName = Server.MapPath("~\\Images\\Item.xls");
 
Share this answer
 
Comments
M.Narmatha 24-Feb-12 0:18am    
this is also return error...
try this

C#
string ServerSavePath = Server.MapPath("~/Upload");
           string path = Path.Combine(ServerSavePath, fileName);
 
Share this answer
 
v2
Comments
M.Narmatha 24-Feb-12 1:17am    
not working...
Try this

C#
string despath = HttpContext.Current.Server.MapPath("~/Upload/clogo/" + filePathtoSave);
 
Share this answer
 
Comments
M.Narmatha 24-Feb-12 2:27am    
not working.....

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