Re: [PHP] Reading binary file data into variable
I have one for windows, think it works with PHP4 aswell, not sure where i put it so let me know if you require it and Ill dig it up? problem is it wont work on Linux. Jay Blanchard wrote: [snip] Did you try using fopen's binary safe read? Something like : [/snip] Shy of being able to do this in the way that I imagined, does anyone know of a class (not requiring PHP 5, as one does on phpclasses.org) that will allow me to specify several PDF and/or other files in a directory to be zipped up so that the archive can be unzipped by the great unwashed at some point? TVMIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading binary file data into variable
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 :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reading binary file data into variable
Jay Blanchard wrote: 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 :) Did you try using fopen's binary safe read? Something like : $binary_data = ; $fp = fopen ( $file, rb ); while ( ! feof ( $fp ) ) { $binary_data .= fgets ( $fp ); } fclose ( $fp ); Don't know if it will work (or if you already tried it)...more like a guess. PS don't trust that Nichel guy, he's really a HTML monkey using Front Page. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading binary file data into variable
[snip] Did you try using fopen's binary safe read? Something like : $binary_data = ; $fp = fopen ( $file, rb ); while ( ! feof ( $fp ) ) { $binary_data .= fgets ( $fp ); } fclose ( $fp ); Don't know if it will work (or if you already tried it)...more like a guess. [/snip] Yes, tried that. It throws an error when trying to open the ZIP file missing 1 byte in Zip File... [snip] PS don't trust that Nichel guy, he's really a HTML monkey using Front Page. [/snip] But I think I can make him buy us all a beer one day. BTW, even though this is Texas I found some Dixie the other daymm delicious Dixie Beer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Reading binary file data into variable
[snip] Did you try using fopen's binary safe read? Something like : [/snip] Shy of being able to do this in the way that I imagined, does anyone know of a class (not requiring PHP 5, as one does on phpclasses.org) that will allow me to specify several PDF and/or other files in a directory to be zipped up so that the archive can be unzipped by the great unwashed at some point? TVMIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php