0

我在 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"');
}

每件事似乎都是正确的。但它仍然没有显示任何文件。

4

1 回答 1

0

在 .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 更改配置 AllowOverride All

于 2013-07-09T09:47:36.823 回答