我尝试在 php 中呈现一个 zip 文件。代码:
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="file.zip"');
下载的文件,只有几个字节。这是一条错误消息:
<br />
<b>Fatal error</b>: Allowed memory size of 16777216 bytes exhausted (tried to allocate 41908867 bytes) in <b>/var/www/common_index/main.php</b> on line <b>217</b><br />
我不希望增加 php.ini 中的 memory_limit。有哪些替代方法可以在不修改全局设置的情况下正确呈现大型 zip 文件?