©
This document uses PHP Chinese website manual Release
(PHP 5)
ibase_blob_echo — Output blob contents to browser
$blob_id
)$link_identifier
, string $blob_id
)This function opens a BLOB for reading and sends its contents directly to standard output (the browser, in most cases).
link_identifier
An InterBase link identifier. If omitted, the last opened link is assumed.
blob_id
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
[#1] jure dot sah at monoliths dot com [2015-08-20 12:06:10]
There is an alternative for getting text out of a blob that does not require as much code. Quoted from a handy online resource:
PHP offers natively the possibility of getting the BLOB data as a string.
For example ibase_fetch_assoc ( resource $result [, int $fetch_flag = 0 ] ) provides the $fetch_flag parameter which can be set to IBASE_TEXT, causing the function to return BLOB contents instead of BLOB ids.
[#2] int21h [2011-07-05 02:11:54]
here is an example if image.php
<?php
if (isset($_REQUEST['imageid']) AND $_REQUEST['imageid']>0) {
$db = 'host:/var/db/mydb.fdb';
$dbusername = 'sysdba';
$dbpassword = 'masterkey';
$query = "SELECT IMAGEDATA, MIME FROM IMAGES WHERE IMAGEID=".$_REQUEST['imageid'];
$dbh = ibase_connect($db, $dbusername, $dbpassword, 'UTF8') or die('Couldn't connect DB');
$result = ibase_query($query);
$data = ibase_fetch_object($result);
if ($data)
{
header("Content-type: ".$data->MIME);
ibase_blob_echo ($data->IMAGEDATA);
}
ibase_close($dbh);
}
?>