Hello everyone,
i am trying to extract blob data into a file and then pass it to the user for download...
The code i wrote should work, but as i have tested it so far it crashes my apache server. I am using apache version 2.2.14, php version 5.2, DB2 9.5 fix pack 2. My connection is open over ODBC ( $conn=odbc_conn ect('SAMPLE','U SER','PASS') )
This is the code:
Appache gives me this error:
[Mon Oct 18 10:00:24 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Mon Oct 18 10:00:24 2010] [notice] Apache/2.2.14 (Win32) PHP/5.2.12 mod_jk/1.2.30 configured -- resuming normal operations
[Mon Oct 18 10:00:24 2010] [notice] Server built: Sep 28 2009 22:41:08
[Mon Oct 18 10:00:24 2010] [notice] Parent: Created child process 8320
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Child process is running
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Acquired the start mutex.
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Starting 64 worker threads.
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Starting thread to listen on port 80.
I have tryed using this on example X.JPG and it returned half of the picture. The server didnt crash tho. Then i tryed it on a PDF - name used some special characters ( PRP_77_DEJAN_20 100409_152103.p df ) the server crashed. I tryed it on 10 other files and it always crashes.
Any help will be very apriciated.
If you have a better idea on this or how to do this without saving a file to filesistem and just direct transfer to user, that would be even better.
With regards,
Marko
Edited:
I changed the way i transfer files from odbc to PDO odbc since in odbc i just set the vairable to some string variable.
Now i can get a file that is rager then 32K out of the DB but it seems i get an timeout on files larger then 100k ( from what i have tested so far ).
This seems to be an apache issue tho so i will close this down and try to get some help there.
i am trying to extract blob data into a file and then pass it to the user for download...
The code i wrote should work, but as i have tested it so far it crashes my apache server. I am using apache version 2.2.14, php version 5.2, DB2 9.5 fix pack 2. My connection is open over ODBC ( $conn=odbc_conn ect('SAMPLE','U SER','PASS') )
This is the code:
Code:
$sql = "SELECT file, filename FROM file where filename = 'a.txt'";
$res = odbc_exec($conn, $sql);
if (!$res)
{exit("Error in SQL");}
$filename = './Datoteke/'.$Datoteka;
$Blob=odbc_result($res, "file");
$filename=odbc_result($res, "filename");
if (is_null($Blob))
{
ECHO " NULL LOB indicated.\n";
}ELSE{
$fh = fopen($filename, "wb");
$noc = strlen($Blob);
for ($i = 0; $i < $noc; $i = $i+2)
{
$hchr = substr($Blob, $i, 2);
$dchr = hexdec($hchr);
$aschr = chr($dchr);
fwrite($fh, $aschr);
}
fclose($fh);
}
[Mon Oct 18 10:00:24 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Mon Oct 18 10:00:24 2010] [notice] Apache/2.2.14 (Win32) PHP/5.2.12 mod_jk/1.2.30 configured -- resuming normal operations
[Mon Oct 18 10:00:24 2010] [notice] Server built: Sep 28 2009 22:41:08
[Mon Oct 18 10:00:24 2010] [notice] Parent: Created child process 8320
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Child process is running
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Acquired the start mutex.
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Starting 64 worker threads.
[Mon Oct 18 10:00:26 2010] [notice] Child 8320: Starting thread to listen on port 80.
I have tryed using this on example X.JPG and it returned half of the picture. The server didnt crash tho. Then i tryed it on a PDF - name used some special characters ( PRP_77_DEJAN_20 100409_152103.p df ) the server crashed. I tryed it on 10 other files and it always crashes.
Any help will be very apriciated.
If you have a better idea on this or how to do this without saving a file to filesistem and just direct transfer to user, that would be even better.
With regards,
Marko
Edited:
I changed the way i transfer files from odbc to PDO odbc since in odbc i just set the vairable to some string variable.
Now i can get a file that is rager then 32K out of the DB but it seems i get an timeout on files larger then 100k ( from what i have tested so far ).
This seems to be an apache issue tho so i will close this down and try to get some help there.