开发者

Access to dynamic images on server

开发者 https://www.devze.com 2023-02-08 21:11 出处:网络
I\'m developing a web application in which users uploads images and I\'m keeping the location of the uploaded image path on server. For example:

I'm developing a web application in which users uploads images and I'm keeping the location of the uploaded image path on server. For example:

C:\fix_directory\a8531.jpg

In my page, I want to display this image but I couldn't. I've tried many things but couldn't find a way of doing it.. This directory isn't par开发者_运维百科t of my project because it will be always updated.

What is the effective way of overcoming this problem?

Thank you


You could setup a virtual directory (yourweb.com/images) which points to your images, or even a web (cdn.yourweb.com).

You could also write a HTTP handler or a file handler (.ashx) in ASP.NET to serve your images from that location.

Update

I guess the most effective way of overcoming this problem would be to store the uploaded files simply somewhere in your web directory.

Update 2

I'm definitley sure, the most effective way of overcoming this problem is to have a real IIS or a Visual Studio Development Server and not trying to do anything with the Vista Home Basic pseudo IIS which can do nothing.


The simplest way would be to make fix_directory a virtual directory within your project inside of IIS, and access the images that way.

A more complex approach would be to do something in the lines of pulling in your image via a FileStream, and outputting it to your website via a ResponseStream.

A common way this is achieved is by creating a generic handler (.ashx) that's only responsibility is to output your images.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号