Richard Korts
asked on
ZipArchive seems not to work
PHP ZipArchive appears not to work.
The source code of my program that uses it (with a lot of echo's) is attached.
When evoking download_docs.php, I get the following:
The source code of my program that uses it (with a lot of echo's) is attached.
When evoking download_docs.php, I get the following:
passed files = doc_files/LS-910-eTCX-System-Brochure.pdf|doc_files/LS-710-TowerClean-Brochure.pdf|doc_files/LS-910-eTCX-System-Brochure.pdf|doc_files/LS-910-eTCX-System-Brochure.pdf~doc_files/LS-911_eTCX_Sample_Spec.doc|doc_files/LS-711-TowerClean-SpecSheet.rtf|doc_files/LS-911_eTCX_Sample_Spec.doc|doc_files/LS-911_eTCX_Sample_Spec.doc~NP_3512.pdf
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/lakoshva/public_html/devdev/download_docs.php:4) in /home/lakoshva/public_html/devdev/download_docs.php on line 27
nd = 8
nf = 3
docs = doc_files/LS-910-eTCX-System-Brochure.pdf
docs = doc_files/LS-710-TowerClean-Brochure.pdf
docs = doc_files/LS-910-eTCX-System-Brochure.pdf
docs = doc_files/LS-910-eTCX-System-Brochure.pdf
docs = doc_files/LS-911_eTCX_Sample_Spec.doc
docs = doc_files/LS-711-TowerClean-SpecSheet.rtf
docs = doc_files/LS-911_eTCX_Sample_Spec.doc
docs = doc_files/LS-911_eTCX_Sample_Spec.doc
internal file name = LS-910-eTCX-System-Brochure.pdf
ifn = doc_files/LS-910-eTCX-System-Brochure.pdf
internal file name = LS-911_eTCX_Sample_Spec.doc
ifn = doc_files/LS-911_eTCX_Sample_Spec.doc
internal file name = NP_3512.pdf
ifn = ../pselsumms/NP_3512.pdf
path = zips/15169zip.zip
Warning: Cannot modify header information - headers already sent by (output started at /home/lakoshva/public_html/devdev/download_docs.php:4) in /home/lakoshva/public_html/devdev/download_docs.php on line 61
Warning: Cannot modify header information - headers already sent by (output started at /home/lakoshva/public_html/devdev/download_docs.php:4) in /home/lakoshva/public_html/devdev/download_docs.php on line 62
Warning: filesize(): stat failed for zips/15169zip.zip in /home/lakoshva/public_html/devdev/download_docs.php on line 63
Warning: Cannot modify header information - headers already sent by (output started at /home/lakoshva/public_html/devdev/download_docs.php:4) in /home/lakoshva/public_html/devdev/download_docs.php on line 63
Warning: Cannot modify header information - headers already sent by (output started at /home/lakoshva/public_html/devdev/download_docs.php:4) in /home/lakoshva/public_html/devdev/download_docs.php on line 64
Warning: readfile(zips/15169zip.zip): failed to open stream: No such file or directory in /home/lakoshva/public_html/devdev/download_docs.php on line 65
download_docs.php
ASKER
David,
OK, I removed all the debug echos that caused the issue. So now, presto, it generates a download file, which is just error messages. It's attached as the txt file.
The new source is attached as well (php).
Very similar script's using Zip Archive work properly configured like this. There is no zip file in the zip folder, as it is empty.
I am almost certain that the code on line 35 does not work.
My suspicion is, since I am working in a SUBDIRECTORY of the others that work, I have not copied something down to tht subdirectory.
Thanks
download_docs.php
download_docs.php
OK, I removed all the debug echos that caused the issue. So now, presto, it generates a download file, which is just error messages. It's attached as the txt file.
The new source is attached as well (php).
Very similar script's using Zip Archive work properly configured like this. There is no zip file in the zip folder, as it is empty.
I am almost certain that the code on line 35 does not work.
My suspicion is, since I am working in a SUBDIRECTORY of the others that work, I have not copied something down to tht subdirectory.
Thanks
download_docs.php
download_docs.php
One problem seems to be here...
Normally you'll write a "\n" to separate your headers + data, which I'm readfile() produces.
Also you still have a previous headers sent message, likely do to the missing "\n" separating request headers + request body.
Also you have no error checking any where, so no way to even guess if your zip operation has worked or readfile has worked.
Best to add error processing for better debugging.
header('Content-type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-length: ' . filesize($path));
header('Content-disposition: attachment; filename=' . basename($path));
readfile($path);
Normally you'll write a "\n" to separate your headers + data, which I'm readfile() produces.
Also you still have a previous headers sent message, likely do to the missing "\n" separating request headers + request body.
Also you have no error checking any where, so no way to even guess if your zip operation has worked or readfile has worked.
Best to add error processing for better debugging.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You guys worked hard, I really don't know the solution, I looked up a sample of using ZipArchive, a very simplistic one & just (carefully) rebuilt what I needed from that base, so it worked.
Thank you
Thank you
1) headers already sent - means you're attempting to send headers + newline twice, so no point in even trying to debug anything else, till you fix this... as this might be your only problem.
2) stat failed for - suggests a permission problem...
3) filesize - suggests filesystem may be full...
4) Also, the zip code moved out of core to a separate module, as of PHP-7.0 so be sure you've also installed your PHP version's zip extension code.
Fix sequence....
1) Ensure your zip extension is installed, so...
Open in new window
or your Distro's package manager command.
2) Fix duplicate header generation.
3) Check permissions... file space usage... inode usage...
4) Then debug anything left over.