So, i have this firebird database, with a " photo " column wich i'm trying to display.
Here is what i've done so far:
- Since ,the content type is unknown ( I'm not the one who created the database, and there is no colomn indicating the type).
- From the first 20 character of the blob data i guess it's a bmp.
Here's a sample code :
Before this : code to connect, run a query to get the table and fetch the result as object ( everything works fine until here)
$blob_data = ibase_blob_info($row->PHOTO);
$blob_hndl = ibase_blob_open($row->PHOTO);
$bl = ibase_blob_get($blob_hndl, $blob_data[0]);
header('Content-type : image/x-xbitmap');
ibase_blob_echo($row->PHOTO);
echo "<dt><strong>Technician Image:</strong></dt><dd>" .
'<img src="data:image/x-xbitmap ;base64,'.
base64_encode($bl).
'" width="290" height="290">' . "</dd>";
$filename = $bl ? dirname(__FILE__)."/img/product__$NUM.bmp" : dirname(__FILE__)."/img/no_pic.bmp";
if ($bl) fwrite(fopen($filename, 'w'), $bl);
As you can see i've tried to :
- Display the blob data using "ibase_blob_echo"
- Display the blob using img tag
- Save it as a file
First one show raw data of the blob, the second nothing and the third result in a corrupted file.
Concerning the Content-type header i've tried
- image/bmp ,x-portable-bitmap, x-xbitmap , jpg, gif, png
Now i'm out of ideas ...