【发布时间】:2011-12-12 11:58:18
【问题描述】:
似乎我成功地创建了一个即时 zip 存档(filesize 和 file_exists 都返回预期值)但是当我尝试实际下载它时,我收到一个空的 ZIP 文件。 奇怪的是,readfile 和 fread 都会出现这个错误。这是我的代码
$filename = $zip;
$handle = fopen($filename, 'r');
if ($handle === false)
{
die('Could not read file "' . $filename . '"');
}
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="fsdownload.zip"');
header('Cache-Control: private');
while (!feof($handle))
{
echo fread($handle, 8192);
}
fclose($handle);
这适用于
【问题讨论】:
-
php错误日志有什么要说的?
-
试试 fpassthru。还有下载需要多长时间?
标签: php download zip on-the-fly