csjoseph
csjoseph

Reputation: 159

retrive file path from database to set Image control

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.

Upvotes: 1

Views: 1088

Answers (1)

nick_w
nick_w

Reputation: 14938

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); 

Upvotes: 2

Related Questions