PCHomepage
Programmer
I need to upload a PDF file into a MySQL database rather than to the file system and it's working but I'm not sure if the data stream is proper. The basic code for creating the data is here (I left out the MySQL calls as it is not the issue) so the variable $content should contain the necessary data.
However, viewing the raw data I see
which does not appear to be in an expected format. I'm not sure what I expected but this looks nothing like any other data files I've inserted in the past, which were mainly images.
For viewing the file, I am using (database code omitted):
and the resulting file is about the proper size but attempts to open it in Adobe Reader gives an Out or Memory error and Adobe Acrobat just opens to a white screen. I think I missed something necessary in the inserting to MySQL code. Any ideas?
Code:
$fp = fopen($source, 'r');
$content = fread($fp, filesize($source));
$content = addslashes($content);
fclose($fp);
However, viewing the raw data I see
0x255044462D312E360D25E2E3CFD30D0A3138342030 . . .
which does not appear to be in an expected format. I'm not sure what I expected but this looks nothing like any other data files I've inserted in the past, which were mainly images.
For viewing the file, I am using (database code omitted):
Code:
Header("Content-type: application/pdf");
Header("Content-Disposition: attachment; filename=$ImageName");
and the resulting file is about the proper size but attempts to open it in Adobe Reader gives an Out or Memory error and Adobe Acrobat just opens to a white screen. I think I missed something necessary in the inserting to MySQL code. Any ideas?