2012-02-23 11 views
2

firebirdにブログ画像を挿入するには?Blob Image on Firebird

ibexpertを使用して正常に挿入できましたが、ウェブアプリケーションからアクセスすると表示されません。

これを解決するには?

+0

あなたはそれを挿入または取得したいですか? – EMBarbosa

答えて

4

PHPサンプル(PHP5-のInterBaseとのphp5-GDモジュールが必要)

 

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);