Reading binary file data into variable
| From: | Jay Blanchard | Date: | Wed, 15 Jun 2005 18:51:03 +0000 |
| Subject: | Reading binary file data into variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-217023@lists.php.net to get a copy of this message | ||
I am following Coggeshall's article on Zend for creating ZIP files. I
seem to have run into a problem with PDF's though.
In his code you have to read the file into a variable. I have tried
file_get_contents, readfile, a combination of fopen, fpassthru, etc....
$filedata = readfile(INVOICEDIR."AOM.1075.542.54243641075B05130.pdf");
The next line in this little jewel runs the data through the ZIP
routines,
$zipfile->add_file($filedata,
"tempzip/AOM.1075.542.54243641075B05130.pdf");
I stayed up too late last night and got up too early this morning, so I
am just brain-farting on what I should do here. How do I get (or can I
get) the PDF data into the variable so that it comes out smelling like a
rose on the other end of the train where the ZIP file get opened and the
individual files are exapndable?
BTW, I have tested this with text too. I am having some problems there
as well, because file_get_contents seems to leave things 'short'.
However, if I fopen the text file and read the text into a variable I
can do the output side.
I appreciate any and all insight into this problem, even Nichel's :)