douqiao6563 2013-07-03 13:30
浏览 45

X-SendFile不支持centos

i have the following intallation on cents 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 .

in httpd.conf i have added the line: LoadModule xsendfile_module /usr/lib64/httpd/modules/mod_xsendfile.so

and apache_get_modules(); shows mod_xsendfile in loaded mod array... Now i have the .htaccess file which contains

<Files files.php>
XSendFile on
</Files>

and the files.php have

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

every things seems corrects. but still it is not show any file.

  • 写回答

1条回答 默认 最新

  • douzhuo1853 2013-07-09 09:47
    关注

    In .htacess file you have

    <Files files.php>
      XSendFile on
    </Files>
    

    and the files.php is

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

    dont forget to change cofig AllowOverride All for .htaccess

    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制