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 PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01