Hello everbody, I uploaded a image to server and want to show image on Image control by ASP. My code
String filename = FileUpload1.PostedFile.FileName;
string strFilename = Server.MapPath("Sample") + "//" + filename;
FileUpload1.PostedFile.SaveAs(strFilename);
//Show Image
Image2.ImageUrl=strFilename ;
But it does not run. Can you help me to show a image on server.Thanks
Display Image from Folder on Server
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Dinesh BeniwalRank #9 · 64K reputationPosted Sep 13, 2011, 11:06 PM EDT
If Satish's answer help you then Mark as accepted answer.
Thanks
Satish BhatRank #2,496 · 563 reputationPosted Sep 13, 2011, 10:17 PM EDT
Try the following code.
String filename = FileUpload1.PostedFile.FileName;
string strFilename = Server.MapPath("Sample") + "\\" + filename;
FileUpload1.PostedFile.SaveAs(strFilename);
//Show Image
Image2.ImageUrl= "~/Sample/" + filename ;
// Here I am asuming that 'Sample' folder is directly under the application root. Otherwise change the path accordingly.
toanhoi bui70 reputationPosted Sep 13, 2011, 11:01 PM EDT