Page 1 of 1

[SOLVED] show images binaries fom database

Posted: Tue Jan 04, 2005 9:54 am
by mcog_esteban
hi all...
i have been asked to a work where i have to insert images binaries in a database, (first i didn't understood i to insert a binary in db, when we can save only the path to the image), i have manage that, but the problem now is to show them.

First try:
i read the data from db and made a file in disk to access it.
this work's, but i don't see the point in having 2 binaries, and having to delete the image from disk later.

Second try:
make a image using GD.
the last two lines of code are

Code: Select all

<?php
header ("Content-type: image/png"); 
ImagePng ($img_handle);
?>
and i only see junk.

i can see it if i don't have any other html in the page, but that's not what i want.

can someone help me with this?
there's another way to see the binaries from the db besides this two?

Posted: Tue Jan 04, 2005 10:02 am
by feyd
images are sent in a seperate stream than html. What you need is a downloader type script that does the lookup into the database and retrieves 1 image for each request. The fun part: this requires 1 database query, 1 script call, and a bunch of pain for each image. Putting often used binary information into a database is normally not recommended for these very reasons.

Posted: Tue Jan 04, 2005 10:42 am
by mcog_esteban
thanks feyd.
i have done the script type downloader and it worked
thanks again