Jump to content
php.lv forumi

Darbs ar BLOB datiem


hoho

Recommended Posts

Sveiki! Man ir Interbase datubāze, kurā glabājas dokumenti BLOB laukā (jpg, gif, pdf, doc ect).

Vai varat palīdzēt atrast piemēru kā uzģenerēt failu pēc šī blob lauka? Nevis tikai attēlot pec uzģenerēt fiziski ... nevaru atrast nevienu piemēru ... :(

Link to comment
Share on other sites

Hm, tā man nesanak. Tiek izveidots fails, bet atvērt nevar.

Mans kods:

 

$sqlAtt2 = "select ATTACH from MAIL_ATTACH where ID= 10";

$result2 = ibase_query($sqlAtt2);

$data = ibase_fetch_object($result2);

$blob_data = ibase_blob_info($data->ATTACH);

$blob_hndl = ibase_blob_open($data->ATTACH);

 

ob_start();

header("Content-type: ".$att_mime);

 

print ibase_blob_get($blob_hndl, $blob_data[0]);

 

$filename = "./files/test.pdf";

$t = ob_get_clean();

file_put_contents($filename, $t);

 

Mana gadijumā arī tiek izveidots fails, $att_mime ir korekts, faila izmērs arī ir pareizs, bet atvērt nevar ...

Link to comment
Share on other sites

varbuut sitaa pameegini ...

 <?php

 $sqlAtt2   = "select ATTACH from MAIL_ATTACH where ID= 10";
  $result2	= ibase_query($sqlAtt2);
  $data  	= ibase_fetch_object($result2);
  $blob_data = ibase_blob_info($data->ATTACH);
  $blob_hndl = ibase_blob_open($data->ATTACH);
 $filename = "./files/test.pdf";
 file_put_contents($filename, ibase_blob_get($blob_hndl, $blob_data[0]));
?>

sitaa rinda man liekas ka ir nevietā ... header("Content-type: ".$att_mime);

Link to comment
Share on other sites

Ar failu viss kārtībā, viss sakrīt. Skripts:

<pre class="prettyprint"> <?php  $sqlAtt2   = "select ATTACH from MAIL_ATTACH where ID= 10";   $result2 	= ibase_query($sqlAtt2);   $data        = ibase_fetch_object($result2);   $blob_data = ibase_blob_info($data->ATTACH);   $blob_hndl = ibase_blob_open($data->ATTACH);  $filename = "./files/test.pdf";  file_put_contents($filename, ibase_blob_get($blob_hndl, $blob_data[0]));?>

Mēģinu visu ierakstīt log failā:$blob_data[0] = 138916 .$blob_hndl : Resource id #52ibase_blob_get($blob_hndl, $blob_data[0]) - neko neatgriež un neieraksta log failā ...Vai ir vēl kādas idējas?</pre>

Edited by hoho
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...