从我的网站下载zip文件后,“找不到中心目录签名”

时间:2017-01-11 21:27:52

标签: 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 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文件?

0 个答案:

没有答案