we have a website that stores PNGs, and PDFs. We use an upload process to
stuff it into the database, and then have some SQL calls to view the images
and PDFs right from the DB. I will post some code in about an hour.
From: Pete French [mailto:pfrench@stripped]
Sent: Wednesday, June 06, 2001 4:29 AM
To: DKatcher@stripped; mark.moline@stripped; sgilley@stripped;
Subject: RE: Storing Pictures or other file types in a MYSQL database
> It's my understanding that it's even harder to get it out once you have it
> in. Would love to see code of how to display a picture on a web page
> retrieving it from the database.
I'm confused as to what the problem is - any select from mysql returns
a MYSQL_RES strusture an you call mysql_fetch_row() to get the
associated MYSQL_ROW structures for each row returned. These contain
a pointer to the data and its length - that how all results of
a select are retuned whether text data or binary data. Any API built on
top actually has to do work in order to have the return values treated as
strings and not binary data in fact...?
Code to display a picture on a web page ? Probably the simplest
is to make the SRC of the image point at a cgi script which
returns the binary data for the image.