I want to comment for this post "link" , but my reputation is lower tan 50, so I have to ask nearly the same question again.
I get the following error message from unzip (after downloading it from my website).
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive. unzip: cannot find zipfile directory
in one of foo.zip or foo.zip.zip, and cannot find foo.zip.ZIP, period.
On my lampp server (testsetup) (at /opt/lampp/myprojects/tmp/foo.zip) unzip works perfect ( no error messages).
I am using this code:
$filename = 'foo.zip';
$path = '/opt/lampp/myprojects/tmp/foo.zip';
if(!file_exists($path))
{
die('Error: file not found');
}
else {
$handle = fopen($path, "r");
header('Content-Description: File Transfer');
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
flush();
readfile($path);
fclose($handle);
Can anybody see my mistake and help me to solve this problems? I am trying to fix it for about 5h but I am not able to solve the problem.
question from:
https://stackoverflow.com/questions/65927206/can-create-zip-archive-in-php-but-cannot-download-it-correctly2 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…