PHP readfile() and large downloads(PHP readfile() 和大量下载)
问题描述
在设置在线文件管理系统时,现在遇到了障碍.
While setting up an online file management system, and now I have hit a block.
我正在尝试使用此 修改后的文件将文件推送到客户端读取文件的版本:
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}
但是当我尝试下载 13 MB 的文件时,它的大小刚好达到 4 MB.这里会出现什么问题?这绝对不是任何形式的时间限制,因为我在本地网络上工作,速度不是问题.
But when I try to download a 13 MB file, it's just breaking at 4 MB. What would be the issue here? It's definitely not the time limit of any kind because I am working on a local network and speed is not an issue.
PHP 中的内存限制设置为 300 MB.
The memory limit in PHP is set to 300 MB.
感谢您的帮助.
推荐答案
您很可能达到了 Web 服务器设置的响应缓冲区限制.众所周知,IIS 和 FastCGI 的默认缓冲区大小为 4mb.我将通过查看网络服务器<->PHP SAPI 配置来开始您的搜索.
Most likely you are hitting the response buffer limit set by your webserver. IIS and FastCGI are known to have 4mb as the default buffer size. I would start your search with looking into the webserver<->PHP SAPI configuration.
这篇关于PHP readfile() 和大量下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP readfile() 和大量下载


- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01