php实现带权限的文件图片下载
有时候我们需要做下载文件,通常是使用类似 PHP readfile函数将文件输出到浏览器,再通过设置mini 类型来实现下载,这样做会有效率问题和网络大量网络IO,那么使用 X-Accel-Redirect 就可以避免这个问题具体配置如下:
nginx配置
location /protected_files {
internal;
proxy_pass https://127.0.0.8/file/; #使用代理
}
#或者
location /protected_files {
internal;
root /var/www/file;
}
//发送本地文件
header("X-Accel-Redirect:/protected_files/10.mp4");
//发送远程文件 最终会转发到https://127.0.0.8/file/file?path=xxx.mp4
header("X-Accel-Redirect:/protected_files/file?path=xxx.mp4");
图片压缩guetzli
最后更新于 2020-01-06 10:44:17 并被添加「」标签,已有 3232 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处