【发布时间】:2015-09-29 06:45:59
【问题描述】:
二进制这是我的问题 我正在使用 php,我为 ZipArchive 库创建了一个 zip 存档。 我用我需要的所有文件完成它并将它保存在我的服务器上。 然后我想让它由当前用户下载,这是我写的:
if (file_exists($zip_archive))
{
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"".$zip_archive."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($zip_archive));
ob_end_flush();
readfile($zip_archive);
}
但是当我下载 zip 压缩包时,我可以看到里面的文件,但是当我尝试解压它们时,出现一个错误,告诉我文件可能已损坏。
所以我尝试打开保存在服务器上的 zip 存档,没有出现错误。
你有什么想法可以帮助我吗?
感谢您的帮助。
(我将 fichier 更改为二进制,但问题仍然存在:存档结束 ...)
【问题讨论】:
-
Content-Transfer-Encoding: fichier是做什么的?你可以尝试使用Content-Transfer-Encoding: binary