1

I used FileUpload control and Server.MapPath to load an image file url to database. Then I want to get this image file url from database and set the Image control in Asp.Net. How can I do that?

When I load the image file url to database is look like this in database:

C:\Users\Joseph\Documents\Visual Studio 2012\Projects\cesme_pano\cesme_pano\Chrysanthemum.jpg

I set this url to Image.ImageUrl control, but it didn't work. How can I solve this problem.

Thanks.

RGO
  • 4,586
  • 3
  • 26
  • 40
csjoseph
  • 159
  • 2
  • 20

1 Answers1

2

Maybe this is what you are looking for. What you are trying to do is convert a physical path to a virtual one that ASP.NET understands.

The suggestion is to go:

String RelativePath = AbsolutePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty); 
Community
  • 1
  • 1
nick_w
  • 14,758
  • 3
  • 51
  • 71