Closed beckspaced closed 10 years ago
Hi,
Do you get any other error messages as well, or line numbers?
I'll have a closer look later.
Cheers A.Grandt
Sent from Samsung Mobile
-------- Original message -------- From: Becki Beckmann notifications@github.com Date: 25/07/2013 09:39 (GMT+01:00) To: Grandt/PHPZip PHPZip@noreply.github.com Subject: [PHPZip] HTML Headers have already been sent from in line 0 (#11)
hi there ;-)
first of all a VERY BIG thank you to the developers of PHPZip!
i got this headers already send error ->
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
the code used for testing is pretty simple & straightforward:
<?php include_once("Zip.php"); $zip = new Zip(); $zip->addDirectoryContent("wp-includes", "wp-includes"); $zip->sendZip("ZipExample1.zip"); ?>
the added directory is found and if i do a var_dump on the directory iterator in the function addDirectoryContent, then i can see all the files.
but i still do get that headers already send error
and if i don't use the addDirectoryContent method and simply add a file instead, it works! without any headers already send error:
<?php include_once("Zip.php"); $zip = new Zip(); $zip->addFile(file_get_contents("readme.html"), "readme.html", filectime("readme.html")); $zip->sendZip("ZipExample1.zip"); ?>
so the problem only exists if i try to add directories ...
hopefully there's someone who can help me track down the problem?
development system used is opensuse 10.3 with php version 5.2.11 and apache 2.2.4
also using the latest PHPZip version from here
thanks & all the best becki
— Reply to this email directly or view it on GitHub.
hi ;-)
thanks for your fast reply ... to make things sure added error reporting into the script
error_reporting(E_ALL); ini_set( 'display_errors','1');
but still no other error messages or line numbers. only that error message from sendZip() function ->
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
thanks & cheers becki
Hi
Please che cl that your script doesn't have an empty space before the first php tag.
Also try to flush the output buffer at the beginning of your script, if i recall you can do it this way ob_start(); ob_flush();
I may be wrong though.
I'll look at the addDirectory code later.
Cheers A.Grandt
Sent from Samsung Mobile
-------- Original message -------- From: Becki Beckmann notifications@github.com Date: 25/07/2013 09:58 (GMT+01:00) To: Grandt/PHPZip PHPZip@noreply.github.com Cc: Asbjørn Grandt asbjorn@grandt.com Subject: Re: [PHPZip] HTML Headers have already been sent from in line 0 (#11)
hi ;-)
thanks for your fast reply ... to make things sure added error reporting into the script
error_reporting(E_ALL); ini_set( 'display_errors','1');
but still no other error messages or line numbers. only that error message from sendZip() function ->
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
thanks & cheers becki
— Reply to this email directly or view it on GitHub.
hi,
if i do flush the output buffer via ob_flush() i get the message that there's nothing to flush ->
Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /zipTest.php on line 6
so i think there's no buffer at all ....
if i then, just out of fun, do remove your !header_sent() check in the function sendZip() to see some line numbers, where actually the headers already have been sent. i receive the following:
Warning: Cannot modify header information - headers already sent in /Zip.php on line 495 Warning: Cannot modify header information - headers already sent by (output started at /Zip.php:495) in /Zip.php on line 496
where line 495 ff says:
header("Pragma: public"); header("Last-Modified: " . gmdate("D, d M Y H:i:s T")); header("Expires: 0"); header("Accept-Ranges: bytes"); header("Connection: close"); header("Content-Type: " . $contentType); header('Content-Disposition: attachment; filename="' . $fileName . '";'); header("Content-Transfer-Encoding: binary"); header("Content-Length: ". $this->getArchiveSize());
hope this helps for debugging ...
thanks & cheers becki
Thanks, I'll get back to you later after having run some tests
Cheers Sent from Samsung Mobile
-------- Original message -------- From: Becki Beckmann notifications@github.com Date: 25/07/2013 10:32 (GMT+01:00) To: Grandt/PHPZip PHPZip@noreply.github.com Cc: Asbjørn Grandt asbjorn@grandt.com Subject: Re: [PHPZip] HTML Headers have already been sent from in line 0 (#11)
hi,
if i do flush the output buffer via ob_flush() i get the message that there's nothing to flush ->
Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /zipTest.php on line 6
so i think there's no buffer at all ....
if i then, just out of fun, do remove your !header_sent() check in the function sendZip() to see some line numbers, where actually the headers already have been sent. i receive the following:
Warning: Cannot modify header information - headers already sent in /Zip.php on line 495 Warning: Cannot modify header information - headers already sent by (output started at /Zip.php:495) in /Zip.php on line 496
where line 495 ff says:
header("Pragma: public"); header("Last-Modified: " . gmdate("D, d M Y H:i:s T")); header("Expires: 0"); header("Accept-Ranges: bytes"); header("Connection: close"); header("Content-Type: " . $contentType); header('Content-Disposition: attachment; filename="' . $fileName . '";'); header("Content-Transfer-Encoding: binary"); header("Content-Length: ". $this->getArchiveSize());
hope this helps for debugging ...
thanks & cheers becki
— Reply to this email directly or view it on GitHub.
hi there again ;-)
today i just thought to run the script on the production server to check if it is an issue with the php version.
this time i got php version 5.3.8 with apache 2.2.21 but the error still remains:
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
so it's probably not a bug in php?
hope this helps ;-0
cheers becki
Hi,
I finally had some time to look at it, and I found the problem. I've committed a new version to Git.
Cheers A.Grandt
On 26-07-2013 08:35, Becki Beckmann wrote:
hi there again ;-)
today i just thought to run the script on the production server to check if it is an issue with the php version.
this time i got php version 5.3.8 with apache 2.2.21 but the error still remains:
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
so it's probably not a bug in php?
hope this helps ;-0
cheers becki
— Reply to this email directly or view it on GitHub https://github.com/Grandt/PHPZip/issues/11#issuecomment-21603910.
hi,
thanks a lot for all your help. but somehow can't find your new version at Git? the most recent change is still listed as 16 days ago ...
thanks & cheers becki
Hi
I forgot to sync the repository. It's there now. Sorry for that.
Cheers A.Grandt
On 26-07-2013 10:50, Becki Beckmann wrote:
hi,
thanks a lot for all your help. but somehow can't find your new version at Git? the most recent change is still listed as 16 days ago ...
thanks & cheers becki
— Reply to this email directly or view it on GitHub https://github.com/Grandt/PHPZip/issues/11#issuecomment-21608824.
awesome ;-) you're a star! got the new version and it works perfect now!
thanks really a lot for your help and that nice piece of code. it helped me a lot!
cheers & fun becki
Resolved. Closing.
hi there ;-)
first of all a VERY BIG thank you to the developers of PHPZip!
i got this headers already send error ->
Error: Unable to send file ZipExample1.zip. HTML Headers have already been sent from in line 0
the code used for testing is pretty simple & straightforward:
<?php include_once("Zip.php"); $zip = new Zip(); $zip->addDirectoryContent("wp-includes", "wp-includes"); $zip->sendZip("ZipExample1.zip"); ?>
the added directory is found and if i do a var_dump on the directory iterator in the function addDirectoryContent, then i can see all the files.
but i still do get that headers already send error
and if i don't use the addDirectoryContent method and simply add a file instead, it works! without any headers already send error:
<?php include_once("Zip.php"); $zip = new Zip(); $zip->addFile(file_get_contents("readme.html"), "readme.html", filectime("readme.html")); $zip->sendZip("ZipExample1.zip"); ?>
so the problem only exists if i try to add directories ...
hopefully there's someone who can help me track down the problem?
development system used is opensuse 10.3 with php version 5.2.11 and apache 2.2.4
also using the latest PHPZip version from here
thanks & all the best becki