Subject | Re: [firebird-php] Re: Show a Jpg stored as Binary blob in a firebird table with PHP |
---|---|
Author | Almond |
Post date | 2003-06-26T04:40:52Z |
The following is the combination of other people's work. It works on my
machine.
<?php
error_reporting(E_ALL);
$db = 'test.gdb';
$user = 'sysdba';
$password = 'masterkey';
$conn=@ibase_pconnect($host.":".$db,$user,$password);
$S = "select images_id, image from images_tbl";
$S .= " where images_id > '0'";
$Q = ibase_query($S);
while ($R = ibase_fetch_object($Q))
{
$TEMPFILE = tempnam("./","TMP");
$TEMPFILE .= ".jpg";
$BLOBID = ibase_blob_open($R->IMAGE);
$FILEID = fopen($TEMPFILE,"w");
//Loop thru the blob, fetching 10K chunks, and write it to the temp file
while ($PIC = ibase_blob_get($BLOBID,10240))
{
fputs($FILEID,$PIC);
}
fclose($FILEID);
ibase_blob_close($BLOBID);
echo "<BR><BR><CENTER><IMG SRC=$TEMPFILE ></CENTER>";
}
ibase_free_result($Q);
ibase_commit();
?>
machine.
<?php
error_reporting(E_ALL);
$db = 'test.gdb';
$user = 'sysdba';
$password = 'masterkey';
$conn=@ibase_pconnect($host.":".$db,$user,$password);
$S = "select images_id, image from images_tbl";
$S .= " where images_id > '0'";
$Q = ibase_query($S);
while ($R = ibase_fetch_object($Q))
{
$TEMPFILE = tempnam("./","TMP");
$TEMPFILE .= ".jpg";
$BLOBID = ibase_blob_open($R->IMAGE);
$FILEID = fopen($TEMPFILE,"w");
//Loop thru the blob, fetching 10K chunks, and write it to the temp file
while ($PIC = ibase_blob_get($BLOBID,10240))
{
fputs($FILEID,$PIC);
}
fclose($FILEID);
ibase_blob_close($BLOBID);
echo "<BR><BR><CENTER><IMG SRC=$TEMPFILE ></CENTER>";
}
ibase_free_result($Q);
ibase_commit();
?>