troya_adromeda
troya_adromeda

Reputation: 627

Blob Image on Firebird

How to insert blog image to firebird ?

I have successfully insert it using ibexpert but when i access it from my web app, it can't show.

HOw to solve this ?

Upvotes: 2

Views: 2007

Answers (1)

rstrelba
rstrelba

Reputation: 1954

PHP sample (php5-interbase and php5-gd modules required)


require("db.php");
require("class.image.php");
header("Content-type: image/jpeg");

$db = db_connect();
$id_s = intval($_GET["id"]);
$id=intval($id_s);  

//
$q = ibase_query($db ,"select ITEMPICS_BODY from ITEMPICS  where ITEMPICS_ID = $id");
$row=ibase_fetch_object($q);
$blob_data = ibase_blob_info($row->ITEMPICS_BODY);
$blob_hndl = ibase_blob_open($row->ITEMPICS_BODY);
$bl = ibase_blob_get($blob_hndl, $blob_data[0]);
ibase_free_result($q);

$w = 640; $h = 640;

$filename = $bl ? dirname(__FILE__)."/img/product__$id.jpg" : dirname(__FILE__)."/img/no_pic.jpg";

if ($bl) fwrite(fopen($filename, 'w'), $bl);
$img = new Image($filename);
$img->resize($w, $h, 1, 0);
$img->toBrowser();

if ($bl) @unlink($filename);


Upvotes: 4

Related Questions