hoho Posted September 4, 2011 Report Share Posted September 4, 2011 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 ... :( Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted September 5, 2011 Report Share Posted September 5, 2011 Nevis tikai attēlot pec uzģenerēt fiziski . Ja zini kā attēlot , tad fiziska ģenerēšana būs to pašu datu ierakstīšana failā, nevis izvadīšana uz skrina. Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 5, 2011 Report Share Posted September 5, 2011 vovo, kaut vai ar ob_start(); // <attēlo to failu un uztaisa $filename> $t = ob_get_clean(); file_put_contents($filename, $t); tas, protams, nav labākais veids, bet ob_* f-jas atrisana katru trešo šajā forumā apspriesto problēmu! :> Quote Link to comment Share on other sites More sharing options...
hoho Posted September 5, 2011 Author Report Share Posted September 5, 2011 Kā pareizi izvadīt BLOB lauku no datu bāzes vienkārši <? echo $row["image_blob"]; ?> Vai arī vajag kaut kā speciāli apstradāt? Quote Link to comment Share on other sites More sharing options...
hoho Posted September 5, 2011 Author Report Share Posted September 5, 2011 <pre class="prettyprint">ob_start();echo $row["image_blob"];$filename = "test.jpg";$t = ob_get_clean();file_put_contents($filename, $t);Fails tiek izveidots, bet ir tukšs</pre> Quote Link to comment Share on other sites More sharing options...
Klez Posted September 5, 2011 Report Share Posted September 5, 2011 (edited) uztaisi tuksu failu, <?php //connect to db.. //get data... file_put_contents($filename, $row["image_blob"]); ?> Edited September 5, 2011 by Klez Quote Link to comment Share on other sites More sharing options...
hoho Posted September 6, 2011 Author Report Share Posted September 6, 2011 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 ... Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 6, 2011 Report Share Posted September 6, 2011 tik minu.. md5 no orģinālā faila un md5 no izveidotā-neatveramā sakrīt? varbūt kaut kādas atstarpes vai kas tomēr pieliekas faila sākumā? Quote Link to comment Share on other sites More sharing options...
hoho Posted September 6, 2011 Author Report Share Posted September 6, 2011 Es izvadu log failå lauku ar blob datiem no datu bāzes un tas ir 0x000001e6000000cb, bet datu bāzē šajā lauka ir daudz vairāk simbolu ... ka tas ir iespējams? Kaut kas un nolasīšanu nav pareizi? Quote Link to comment Share on other sites More sharing options...
Klez Posted September 6, 2011 Report Share Posted September 6, 2011 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); Quote Link to comment Share on other sites More sharing options...
hoho Posted September 6, 2011 Author Report Share Posted September 6, 2011 Mēģinu bez šis rindiņas, vienalga fails tiek izveidots, bet atvert nevar, parādās kļūda - No preview available. Varbūt zini kāpec izvadot šo lauku log failā ir tikai "0x000001e6000000cb", bet reāli datu bāzē ir citi simboli? Quote Link to comment Share on other sites More sharing options...
Klez Posted September 7, 2011 Report Share Posted September 7, 2011 tu failu tajaa db vari iedabūt ? paskaties ar kādu hex editoru kaa izskataas orginalais un kaa izskataas tas kas no db naacis ... Quote Link to comment Share on other sites More sharing options...
hoho Posted September 7, 2011 Author Report Share Posted September 7, 2011 (edited) 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 September 7, 2011 by hoho Quote Link to comment Share on other sites More sharing options...
Klez Posted September 7, 2011 Report Share Posted September 7, 2011 ja abi faili hex editorā izskatās vienādi, tad problēma nav php ne ? Quote Link to comment Share on other sites More sharing options...
marrtins Posted September 7, 2011 Report Share Posted September 7, 2011 (edited) ibase_fetch_row($result2, IBASE_TEXT); Edited September 7, 2011 by marrtins Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.