Displaying an image pulled from database

admin

Administrator
Staff member
I am having trouble getting an image to display after pulling it from the database.

Because my images are be dynamic in the page I cannot rely on printing header information to the page (keep getting errors) and so I am searching for a workaround without using frames.

I got the idea to take the image out of the database and stick it into an temporary file then read the file with a typical <img src> tag. The code I am using to create the temporary file is as follows:

exec ('cat $data > /.../$file_name');

this creates a file say penguin.jpg , I then use a typical <img src> tag with the filename, and I receive an image placeholder on the webpage.

Because it did not work I decided to check the file in the gimp to see if it was a valid jpeg. It appeared to be, then using samba I opened it in the browser it originally failed in directly by double clicking the file. The browser displayed the image correctly. At this point I am stumped. I know the browser can display the image, I can open it with any program that can open images, but I cannot display it with an <img src> tag.

Does anyone know of any additional information I need to add to the file, for example do I need to encode the file type into the image somehow (other than by properly appending the file type to the name)?

Any help would be appreciated.
 
Back
Top