mum
mum

Reputation: 1645

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?

Upvotes: 1

Views: 1578

Answers (1)

Andrew Adamich
Andrew Adamich

Reputation: 707

ImageEdit.ImageUrl = Server.MapPath(filepath);

Try this

ImageEdit.ImageUrl = filepath;

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

Upvotes: 1

Related Questions