如何在不进入allowed memory bytes exhausted
的情况下在PHP中读取/下载大型文件?
我正在尝试:
$content = null;
while (!feof($file['data'])) {
$content .= fread($file['data'], 8192);
}
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"" . $file['real_filename'] . "\"");
header("Content-Length: " . $file['length']);
echo $content;
答案 0 :(得分:1)
你试过这个吗?
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"" . $file['real_filename'] . "\"");
header("Content-Length: " . $file['length']);
while (!feof($file['data'])) {
print fread($file['data'], 8192);
}