我在6美分上有以下安装。
apache version :Apache 2.0
httpd-tools-2.2.15-28.el6.centos.x86_64
httpd-devel-2.2.15-28.el6.centos.x86_64
httpd-2.2.15-28.el6.centos.x86_64 .在httpd.conf中,我添加了一行: LoadModule xsendfile_module /usr/lib64/httpd/modules/mod_xsendfile.so
和apache_get_modules();显示加载的mod数组中的mod_xsendfile ...现在我有了包含以下内容的.htaccess文件
<Files files.php>
XSendFile on
</Files>而files.php有
$path='fileliste.txt';
$documentMIME="text/plain";
$modules = apache_get_modules();
if (in_array("mod_xsendfile", $modules)) {
header ("X-Sendfile: ". $path);
header ("Content-Type: " . $documentMIME);
//header ('Content-Disposition: attachment; filename="textfile"');
}每件事似乎都是正确的。但是它仍然没有显示任何文件。
发布于 2013-07-09 17:47:37
在.htacess文件中
<Files files.php>
XSendFile on
</Files>而files.php是
<?php
$file = "path_to_your_file";
$finfo = new finfo;
$mime = $finfo->file($file, FILEINFO_MIME_TYPE );
if (in_array('mod_xsendfile', apache_get_modules()))
{
header("X-Sendfile: $file");
header("Content-type: $mime");
//header ('Content-Disposition: attachment; filename="image"');
}
?>不要忘了为.htaccess更改cofig AllowOverride All
https://stackoverflow.com/questions/17449376
复制相似问题