Forum Moderators: coopster

Message Too Old, No Replies

determining file type from mysql BLOB

trying to determine image type from BLOB data

         

kapalselam2

1:21 am on Aug 23, 2006 (gmt 0)

10+ Year Member



Hi,

Is there any way to get file type from blob data? I have a that contains images for my site, but it doesnt have file type on the table. Basically i just use image/jpeg for all the images. Will this affect the decoding by the browser if I make everything to image/jpeg? If I want to set the file type manually, how can I do that? I found the magic numbers for gif (0x47494638) and jpeg (0x4a464946).

I tried to HEX the blob data in mysql using select HEX(image_blob_data)as hex_value from images. And then do str search with that hex_value in php script. But it didnt work. I tried on different pc and it was working and I could locate the magic numbers.
Is this because when the image was uploaded, it uses base64_encode before putting the value into blob?

Thank you...

siMKin

1:37 pm on Aug 23, 2006 (gmt 0)

10+ Year Member



it's not possible in mysql
what you could do is safe everything as a file on the HD and then use
[nl2.php.net...]
to determine the filetype

of course it would be much much MUCH better if you had control over the proces of storing the data in the database and save the filetype in a seperate field