Subject | AW: AW: [firebird-php] Show a Jpg stored as Binary blob with PHP IT WORKS NOW! |
---|---|
Author | Gerhard Knapp |
Post date | 2003-06-26T10:38:06Z |
HIIIIIIIIIIIIIIIIIIII ALMOND!
NOW IT WORKS!
The last problem was a "windows" different fopen mode thing:
On windows-system i needed: $FILEID = fopen($TEMPFILE,"wb");
the b in "wb" forces PHP to open the file in binary-mode ...
thank you very much for your help!
best regards
-Gerhard
-----Ursprungliche Nachricht-----
Von: Almond [mailto:almond@...]
Gesendet: Donnerstag, 26. Juni 2003 07:09
An: firebird-php@yahoogroups.com
Betreff: Re: AW: [firebird-php] Show a Jpg stored as Binary blob in a
firebird table with PHP
The following is the combination of other people's work. It works on my
machine.
<?php
error_reporting(E_ALL);
$db = '/data/html/phpgem312/test.gdb';
$user = 'sysdba';
$password = 'masterkey';
$conn=@ibase_pconnect($host.":".$db,$user,$password);M
$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);
//UNIX:
$FILEID = fopen($TEMPFILE,"w");
//WINDOWS:
// $FILEID = fopen($TEMPFILE,"wb");
//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();
?>
At 16:54 03/06/25 +0200, you wrote:
header.
"<IMG SRC=\"image.php?id=999\">
ADVERTISEMENT
To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
NOW IT WORKS!
The last problem was a "windows" different fopen mode thing:
On windows-system i needed: $FILEID = fopen($TEMPFILE,"wb");
the b in "wb" forces PHP to open the file in binary-mode ...
thank you very much for your help!
best regards
-Gerhard
-----Ursprungliche Nachricht-----
Von: Almond [mailto:almond@...]
Gesendet: Donnerstag, 26. Juni 2003 07:09
An: firebird-php@yahoogroups.com
Betreff: Re: AW: [firebird-php] Show a Jpg stored as Binary blob in a
firebird table with PHP
The following is the combination of other people's work. It works on my
machine.
<?php
error_reporting(E_ALL);
$db = '/data/html/phpgem312/test.gdb';
$user = 'sysdba';
$password = 'masterkey';
$conn=@ibase_pconnect($host.":".$db,$user,$password);M
$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);
//UNIX:
$FILEID = fopen($TEMPFILE,"w");
//WINDOWS:
// $FILEID = fopen($TEMPFILE,"wb");
//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();
?>
At 16:54 03/06/25 +0200, you wrote:
> >$sst = "SELECT image, image_type FROM images_tbl WHERE images_id='123''";
> >$result = ibase_query($sst, $f);Sorry, I use a sql lib.
> >if(empty($result)) echo SQL_error($f,$sst)."<BR>";
> >$tmprow=SQL_fetch_object($result,0);
>
>you mean ibase_fetch_object ??
> >$image = $tmprow->image;image/jpeg, it looks like IE6 can echo the picture w/o it.
> >header("Content-type: ".$tmprow->image_type);
>
>i have no imagetype stored in db, what is the value for image_type? "JPG"
>p.e.?
> >headers_sent();The above method is used by calling an external php, so, there is always a
>here comes the error, headers was sent before, sorry -..
>ibase_blob_echo($image);
header.
"<IMG SRC=\"image.php?id=999\">
>id doesn't work ...Yahoo! Groups Sponsor
>have an working example???
>
>thank you
>best regards
>-Gerhard
ADVERTISEMENT
To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.