Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Binary Data

Status
Not open for further replies.

phart

IS-IT--Management
Sep 20, 2001
76
US
I have images stored in a database. I would like to display them on my web pages. I know that I need to use Response.BinaryWrite( bdata) but when I do all that shows is the the binary data not the image, like the data is not being decoded.

page 1.asp

<body>
<img src="getthumb.asp?TNID=1" />
</body>

getthumb.asp

if not (rs.eof and rs.bof) then
Thumb = rs("thumbnail")
Response.ContentType = "image/jpeg"
Response.BinaryWrite Thumb
End If
...

I am using IIS5.1 is there something that I am missing.

 
Interesting question. Are you sure you are pulling jpeg images from the database??

[monkey][snake] <.
 
Yes they are. I set up a test table ad placed jpgs in the test table myself.
 
Question if I may. What code are you using to store the images in the database?

[monkey][snake] <.
 
On my test table I am just using insert object from file and browsing for the jpg. This is an access database right now. When I insert the object and set up a small form the image displays in access, but not when I try to retrieve it from ASP.
 
One thing you have to be absolutely sure not to do is allow any spaces, line feeds, etc occur outside iof your ASP script tags for the getthumb.asp page. If you do these will get carried along as part of the binary data and, of course, you end up with no image.

This may seem obvious or it may not, heck I even did it one time myself and it took me hours to find the trailing line feed at the end of my file.

Not saying this will be the solution, just some to check for,
-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top