大文件下载的feof替代方案是什么?
我使用这个 while 循环来获取文件;
<?php
while(!feof($fp)){ //get this file with feof but dont tell file location on the server
$buffer = fread($fp,$sizechunk);
echo $buffer;
ob_flush();
flush();
}
但 feof
不适合大容量下载。因为我正在提供大文件,并且下载必须完成才能退出 while
循环。从循环中退出非常简单,但我需要退出循环并且下载将继续。或者我需要用另一个代码来拉它。有什么想法吗?
由于文件停留在循环中,PHP似乎一直在使用,如果我不能删除它,下载次数超过6后PHP就会崩溃。
我尝试了以下服务器端更改;
在 PHP 设置中:
max_execution_time = 60 to 3600
max_input_time = 30 to 7200
max_input_vars = 30 to 7200
post_max_size = 200M to 200000M
memory_limit = 2000M to 30000M
sub process = 20 to 200
I use this while
loop to fetch the file;
<?php
while(!feof($fp)){ //get this file with feof but dont tell file location on the server
$buffer = fread($fp,$sizechunk);
echo $buffer;
ob_flush();
flush();
}
But feof
is not good for large downloads. Because I'm serving large files and the download must be complete before it can exit the while
loop. Exit it from the loop is very simple, but I need to exit the loop and the download will continue. Or I need to pull it with another code. Any idea?
Since the file stays in the loop, PHP seems to be used continuously and if I can't remove it, PHP will crash after the number of downloads is 6+.
I tried the following server-side changes;
In PHP settings:
max_execution_time = 60 to 3600
max_input_time = 30 to 7200
max_input_vars = 30 to 7200
post_max_size = 200M to 200000M
memory_limit = 2000M to 30000M
sub process = 20 to 200
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论