문제

Generally,if we want to display a image in the web page,we give the uri of the image resource like: http://host:port/image/xxx.jpg.

Now,there are some images in my file system,and I save its absolute path in the db.

Like this;

id     name     address   image
1      xxxx     xxxx      C:/images/xxx.jpg

Now if the entity is retrived,its image should be displayed in the page.

How to make it?

What I thought is copy the image under the web server dir,then build its url,then the page can render it. But I wonder if this is a good idea? Is there any other way?

도움이 되었습니까?

해결책

You could create a webpage or a httphandler which retrieves the requested image from the database then send it to the user using httpresponse and the correct mimetype. Using the querystring the image is identified like:

Unfortunately you didn't specify the programming language you are using. If its .Net I could create some example code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top