It depends on the type of "blob" you are storing in the db. If you are storing gif
images in the blob field, then you would retrieve the data from the database
and send it out after sending a header like so:
header ("Content-type: image/gif");
Keep in mind that you can not have the same script send out the html and the
blob. Have one script generate the page html with tags to the image like so:
<IMG SRC="sendblob.php?id=xxxxx">
Or if your blob is some kind of download file that you want (like an mp3) then
create a link like so:
<A HREF="sendblob.php?id=xxxx">Download now!</A>
In both cases, "sendblob.php" would use the "id" field and value to retrieve the
blob from the db, send the appropriate header, and then send the blob data.
If you want a list of all standard media types/sub-types go here:
http://www.isi.edu/in-notes/iana/assignments/media-types/media-types
Also, if you want to send something that will always prompt the user to "save to
disk", then send:
header("Content-Disposition: attachment;
filename=whatever.mp3");
This allows you specify that the browser is to prompt for a "save" and will even
let you "suggest" the name for the file to be saved as (although the user can
always override this name".
I hope this helps you out.
PS:
Some dbms's have better support for BLOB's than others, and some don't
support them at all. Unless I am coding something very specific, I tend to keep
my apps portable and so I don't use BLOB's most of the time. Instead, I save
the files to a disk location and just store the filename in the db. When the time
comes, I send the proper headers and then use the fpassthru() command
to send out the file.
-- Rich Rijnders
-- Irvine, CA US