Physical Path for image saving. Asp.net

2019-08-24 07:33发布

问题:

I have a web project and I saved my images in Physical folders in hdd Like d:\SecretImages\Imagename. But I can't open the files when I have to?

I thought if it can saves for examle d:\SecretImages\Temp.jpg, I can open when I have to but, I can't.

Help me please, thanks

回答1:

You cannot use file paths to show your images. The browser doesn't know where to find the images and the server wouldn't serve them up anyway due to security concerns.

You could/should use an HttpHandler to show the images.

I answered a similar question here on SO how to do this.



回答2:

its becus when iis get file, it get as ASP.NET user not local system user. just go to the folder and add IIS_IURS group to permission list. or just set folder accessible by everyone. this type of problem mostly not occur when local debugging. but will happen in production or network storage.



回答3:

Try this article

http://www.aspsnippets.com/Articles/Display-Images-in-GridView-Control-using-the-path-stored-in-SQL-Server-database.aspx