X-sendfile 大文件下载解决方案

使用PHP下载大文件文件,有时候还需要修改PHP配置。比如:

https://javascript.net.cn/article?id=613 有时候下载还会过多的暂用内存。


这里可以使用X-sendfile,该下载方法,不经过PHP,文件直接通过 Apache 下载。


.htaccess

<Files out.php>

XSendFile on

</Files>


out.php

isLoggedIn())
{
  header("X-Sendfile: $path_to_somefile");
  header("Content-Type: application/octet-stream");
  header("Content-Disposition: attachment; filename=\"$somefile\"");
  exit;
}
?>
Permission denied


Login first!






参考:https://tn123.org/mod_xsendfile/


声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。
随机推荐
WordPress 密码生成和密码验证
CSS 边框与边距
视频剪辑软件 Shotcut 笔记
JavaScript Proxy 代理
Windows 服务命令 sc
CSS 基本语法
Node.js crypto 模块
Notifications API