| Posted by Petr Vileta on 09/12/06 15:06 
jackpod wrote:> Hi,
 > I have been trying to write an image to a database table BLOB field in
 > MySQL but when I try to retrieve the image to display it, it shows as
 > being empty. Are there any special considerations I need to take into
 > account when reading and writing images to a DB? Thanks.
 Writing images into database is not good idea expect if the images are very
 small. Better is to create some upload directory and save images here. Into
 database you write the (generated) filenames only. The procedure is some
 like this:
 
 IF file is attached (uploaded)
 genetare new unique filename
 get file extension from original filename
 save attached file into upload directory as
 generated_filename.original_extension
 put new filename into some table
 ENDIF
 
 And procedure for viewing in browser is like this
 
 IF ! EMPTY(filename in table)
 echo "<img src=\"upload_directory/$filename\">";
 ENDIF
 
 --
 
 Petr Vileta, Czech republic
 (My server rejects all messages from Yahoo and Hotmail. Send me your mail
 from another non-spammer site please.)
 [Back to original message] |