Using X-Sendfile with Apache/PHP

大城市里の小女人 提交于 2019-11-26 04:49:15

问题


I can\'t seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code).

Anyone used it before and would mind giving a quick snippet of code and a brief description?


回答1:


X-Sendfile is an HTTP header, so you want something like this:

header("X-Sendfile: $filename");

Your web server picks it up if correctly configured. Here's some more details:

http://www.jasny.net/articles/how-i-php-x-sendfile/




回答2:


If tweaking the web server configuration is not an option, consider PHP's standard readfile() function. It won't be quite as fast as sendfiling, but it will be more widely compatible. Also note that when doing this, you should also send a Content-Type header at the very least.



来源:https://stackoverflow.com/questions/80186/using-x-sendfile-with-apache-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!