Page 1 of 1

Problem extracting BLOB from Interbase !

Posted: Thu Aug 07, 2003 6:31 am
by azis
Hi

I have a problem and hope you can help me

I need to insert an image into the Interbase (BLOB SUB_TYPE 0 SEGMENT SIZE 800)
and afterwards to be able to extract it someware on my web page, but I still can not extract it right

This works but it displays only the image

<?PHP
include("sysvars.php");
$id = 108;

$dbh = ibase_pconnect($hostweb, $username, $password);
$sth = ibase_query($dbh, 'SELECT IMAGE FROM "BROSHURI" WHERE ID=' . $id);

//echo "<br>TEST<br>";

while($row = ibase_fetch_object($sth))
{
ibase_blob_echo($row->IMAGE);
}
?>


If I uncomment the //echo "<br>TEST<br>";
than the image is gone and disppalyed like : BM6@6(U@@3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›3—›/љ&#152;) &#152;1« ‘„(њЏ0 ”$&#152;‹/Ёљ&#152;‰џ”!§›џ&#152;ђЊ:ЎЈDџ¤5Ђ‰YљўV“—4pp%ccO“’FЋЋSЎ C–—<””......................................

I insert it like :
............

$fd2 = fopen ($image, "rb");
$bloby2 = ibase_blob_import($fd2);
.......

I presumed that the headers were the problem but I tried some things and still nothing

Can some one please help me ?
Thanks

Posted: Thu Aug 07, 2003 2:00 pm
by fractalvibes
You need to send a header to set the content-type to the type of object you want to display. Note, you cannot send both text/html and the image from the same page. Create a separate page to server up the BLOB and where you want your image displayed do something like:

<img src='ShowImage.php?ID=108'>

ShowImage.php will set it's content type to image/jpg or whatever and stream to the browser.

Phil

Posted: Fri Aug 08, 2003 4:36 am
by azis
Yes It worked :D

Thanks Phil