Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top