Link to home
Start Free TrialLog in
Avatar of ZKM128
ZKM128

asked on

How to display image on ASP from ADODB.Stream object

Hello,

I need to show images on my ASP. Due to the security reasons, I cannot simply put all of my images in the images folder in my website folder and I need to put them outside of my website folder.
For example, my website folder is located at: C:\Inetpub\wwwroot\mysite\
But I need to put images (which I want to show on my web pages) at: C:\images\

I am trying to use ADODB.stream object to pull the images from C:\Images folder and display the image on my ASP using ASP vb codes as shown below

Name of this ASP: ReadImage.asp
<%
 Response.ContentType = "image/png"
 Set adoStream = Server.CreateObject("ADODB.Stream") 
 adoStream.Open
 adoStream.Type = 1
 FPath = "C:\images\1.png"
 adoStream.LoadFromFile FPath

 Response.BinaryWrite adoStream.Read 

 adoStream.Close
 Set adoStream = Nothing 
 Response.End
 %>

Open in new window

When I launch this webpage in internet explorer, the page shows a File Download window/message for downloading the image file "1.png" rather than displaying the image on the web page.

 I also tried creating another ASP named "DisplayImage.asp" and used the following code to display the image on this page but,

 <img src="ReadImage.asp">

Open in new window


 when I launch this page, the page cannot display the image either.

 Please explain how to change this code to make it work.

 Thank you.
Avatar of Big Monty
Big Monty
Flag of United States of America image

Why not just create a virtual directory in IIS? Is that an option?
If you must stream them have a look at this article:

http://www.chilkatsoft.com/p/p_271.asp
Avatar of ZKM128
ZKM128

ASKER

I don't know how to do this by creating virtual directory. Could you please explain to me in detail how to do it by using virtual directory in IIS?
Avatar of ZKM128

ASKER

Thanks for your help but the example at:

http://www.chilkatsoft.com/p/p_271.asp

doesn't seem to explain how to display the image file on the web page (html or asp) but just explains how to stream and download files.
SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial