Search code examples
sharepointsharepoint-2007

Why does my image not show in SharePoint?


I upload an image in SharePoint:

I save the image file in the folder: IMAGES\\imagewebpart\\

    Random rd = new Random(); 
    int db = rd.Next(0, 100); 
    string filename =Path.GetFileNameWithoutExtension(imagefile) + 
      db.ToString() + 
      Path.GetExtension(imagefile); 
    string filepath ="\\_layouts\\IMAGES\\imagewebpart\\" + filename; 
FileUpload1.SaveAs(Server.MapPath(filepath)); 
    //ImageEdit.ImageUrl =filepath; 
    ImageEdit.ImageUrl = Server.MapPath(filepath);

I can save the file successfully, but I can't display the image to ImageEdit.

Why?


Solution

  • ImageEdit.ImageUrl = Server.MapPath(filepath);

    Try this

    ImageEdit.ImageUrl = filepath;
    

    where filepath = "/_layouts/IMAGES/imagewebpart/" + filename