我试图在Mac上的apache服务器上安装x_sendfile。安装过程似乎一切正常,httpd.conf配置了"LoadModule xsendfile_module "XSendFile ON"“。
如果我从终端运行"httpd -M",我可以在列表中查看"xsendfile_module (共享)“。
但是在phpinfo()或apache_get_modules()中,没有列出x-sendfile。如果我试图在我的php代码中使用x-sendfile下载任何文件,浏览器只会下载一个0 kb的文件。不过,我可以在头数据中看到x-sendfile头标记。
有什么建议吗?
发布于 2012-09-11 22:30:33
确保httpd.conf文件中有这一行。将其添加到页面设置下:
XSendFile On XSendFilePath /dir-哪里-文件获取-下载-从/
发布于 2013-07-12 18:32:37
我在CentOS中遇到了类似的问题。我补充说:
XSendFile On
XSendFilePath /dir-where-the-file-gets-downloaded-from/但是,对于httpd.conf,我还确保在php页面本身使用绝对路径。
header('Content-Type: '.$formatMIME);
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=User_sees_this.pdf");
header("X-Sendfile: 'absolute_path_goes_here'");据我所知,httpd -M是否正在显示已安装的模块,上面的代码应该可以工作。您不会在phpinfo中看到xsendfile,因为它不是php的扩展名。我不能和apache_get_modules()说话。
同样,这是基于我个人经验的评论,而不是一个明确的答案。
https://stackoverflow.com/questions/12334124
复制相似问题