Storing PDF in MySQL
Posted: Wed Jun 08, 2011 7:39 am
I used MySQLYog to upload the 3M PDF file into a record. Reretrieving it from MySQLYog works fine but when I try to retreive that file from PHP in my application it comes out corrupt:
When I debug the damn thing and send the output to error_log() it appears only a portion of the file is being returned, no where near the 3M.
The field type is BLOG. I'm using a simple SELECT data_buffer from table type query - is there special handing required for BLOB's? The PDF magic bytes appear to be present in the first 5 of so bytes of the output so i'm assuming the corrupt is being caused by missing data - not why or how to fix this anyone have any similar experience?
Cheers,
Alex
Code: Select all
// ... controller:action starts
$response->setHeader('Content-Description', 'File Transfer');
$response->setHeader('Content-Disposition', 'attachment; filename=diagram.pdf');
$response->setHeader('Content-type', 'application/pdf');
$response->setHeader('Cache-Control', '');
$response->setHeader('Pragma', '');
$response->setContent($buff);
return true;
// ... controller:action finishedThe field type is BLOG. I'm using a simple SELECT data_buffer from table type query - is there special handing required for BLOB's? The PDF magic bytes appear to be present in the first 5 of so bytes of the output so i'm assuming the corrupt is being caused by missing data - not why or how to fix this anyone have any similar experience?
Cheers,
Alex