[thelist] Streaming a Binary as image src

Warden, Matt mwarden at odyssey-design.com
Mon Mar 19 15:14:42 CST 2001

I did this for PHP for a fellow list member... see below...

> Howdy....
> I want to stream an image "within" the HTML, not as the sole content of the
> page.

Same process either way.

> ShowImage.asp
> <%
>      ImageDir = "Drive:\Dir\SubDir\"
>      ImageName = "Image.gif"
>      Set oFM = CreateObject("SoftArtisans.FileManager")
>      Set oBS = oFM.OpenBinaryFile(ImageDir & ImageName)

I don't know anything about that object, so I'm going to assume that this is

>      Response.ContentType = "image/GIF"
>      Response.Addheader "Content-Disposition", "inline; filename=" &

I didn't have to add the above header. The content-type was all I needed.

>      Response.BinaryWrite oBS.ReadAll
>      'Clean up....
>      Set oBS = Nothing
>      Set oFM = Nothing
>      Response.End
> %>
> I think this was discussed here, but I can't find anything in the archives.
> I'm I off base in this approach?

We discussed it briefly before. I was actually trying to feed a stream into
JavaScript's new Image() object. Basically the same thing... just a few other

Some tips if this image will change (which is why you're doing this, I

add a random querystring to the img tag:
    <img src="./showimage.asp?<%=randomNumber1%>=<%=randomNumber2%>" ...>

I would add Response.Expires = 0 to the top of your image script, even though
the equivalent didn't help me at all in the PHP project I was doing.

There were a couple more issues I ran into that I can't think of off the top
of my head. If you run into a problem, shoot me an email... I probably ran
into it too.



More information about the thelist mailing list