Php &引用;找不到中央目录签名的结尾";从我的网站下载zip文件后
我有一个名为Php &引用;找不到中央目录签名的结尾";从我的网站下载zip文件后,php,zip,nearlyfreespeech,Php,Zip,Nearlyfreespeech,我有一个名为filename.zip的zip文件。我使用FileZilla将其上传到我的网站上的/home/protected目录,该目录由NearlyFreeSpeech.net托管 最近,当我试图下载zip文件并通过在终端中运行unzip filename.zip打开它时,我遇到了以下错误: Archive: filename.zip End-of-central-directory signature not found. Either this file is not a z
filename.zip的zip文件。我使用FileZilla将其上传到我的网站上的/home/protected
目录,该目录由NearlyFreeSpeech.net托管
最近,当我试图下载zip文件并通过在终端中运行unzip filename.zip
打开它时,我遇到了以下错误:
Archive: filename.zip
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 filename.zip or
filename.zip.zip, and cannot find filename.zip.ZIP, period.
大约在上个星期之前,我可以从我的网站上下载这个文件并将其解压
我可以先解压缩文件,然后再将其复制到我的网站
我无法解压缩我随后下载的文件副本
下面是处理下载的PHP
$file = "path/to/file";
if(file_exists($file)){
$handle = fopen($file, "r");
header('Content-Description: File Transfer');
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file));
ob_clean();
flush();
readfile($file);
fclose($handle);
} else {
echo('File does not exist');
}
为什么我不能再正确解压缩下载的zip文件?使用FileZilla检索文件:文件是否已损坏?如果是这样,问题是当您上载文件时(不是在二进制模式下?)。如果不是,问题似乎在php脚本中(但我没有看到任何明显的问题)。@DavidDuponchel当我通过FileZillaYour代码在我的机器上运行时,文件没有损坏(我可以下载一个zip文件,然后解压缩)。您是使用这段代码进行测试,还是作为更大的php脚本的一部分?“上周之前”:有什么变化吗?这是一个更大的脚本的一部分,但在过去几周或之前的几个月里,我什么也没有改变。你能尝试使用一个只包含此代码的临时页面吗?