I am saving my image to a folder SiteImages that resides within project root but I want to place it on my C drive and want to save and access pictures from there i.e. C;/SiteImages but I can't figure out
Code: (Upload)
string fileName = Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/SiteImages/") + fileName);
Code: (Access)
string FilePath = new Uri(Server.MapPath("~/SiteImages/")).AbsoluteUri;
please help to make it work within C drive
UPdate: problem is with gridview picking picture from C drive now.
Old:
<img src='../SiteImages/<%# Eval("PersonalInfoEmployeePicture") %>' width="20" height="20" onmouseover="ShowFull(this)" onmouseout="ShowActual(this)" />
It should be as simple as it is, right?
string fileName = Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs("C:\\SiteImages\\" + fileName);
string FilePath = "C:\\SiteImages\\" + fileName;
UPDATED:
As you said that you want it to be accessed as absolute URI, create a Virtual Directory in IIS pointing to SiteImages folder in C:. With that you can use Server.MapPath
function to map the path into the folder you specified.
just remove the begin ..
in image source
<img src='/SiteImages/<%# Eval("PersonalInfoEmployeePicture") %>' width="20" height="20" onmouseover="ShowFull(this)" onmouseout="ShowActual(this)" />
If you still using below code to save uploaded images
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/SiteImages/") + fileName);