I would like to mention that may it is not clear, but what I wanted to say that both I save to virtual path and read from virtual path. Here is the code that read image:
Image1.ImageUrl = "~/images/employees/" + Request["empID"].ToString() + ".jpg";
Here is the code that upload image:
if (fileUpload.HasFile)
{
// Get the name of the file
string fileName = fileUpload.FileName;
string ext = System.IO.Path.GetExtension(fileName.ToString());
if (ext == ".jpg" || ext == ".jepg" || ext == ".JPG" || ext == ".JPEG")
{
fileName = Request["empID"].ToString() + ".jpg";
// Upload the file on the server
fileUpload.SaveAs(MapPath("~/images/employees/" + fileName));
}
}
Thanks for the try to name it with different name, using time but when i want to render the image, how can I know its name without saving it??!!