dougai3418 2012-07-10 13:46
浏览 99
已采纳

X-Sendfile错误,找不到文件

I'm using apache2 webserver and I have installed mod_xsendfile I have something like:

                header('Content-type: application/zip');
                header('Content-Disposition: attachment; filename="file.zip"');
                //header("X-Accel-Redirect: /file/protected/file.zip"); //for nginx server
                header('X-Sendfile: /protected/file.zip');
                exit();

I enabled in /etc/apache2/apache2.conf:

XSendFile on

When I click on Download button in /file/index.php it gives me error, index.php that is located in /file/ Not Found

I tried moving header('X-Sendfile: /file/protected/file.zip'); at the first place but it's the same..

When I use header("X-Accel-Redirect: /file/protected/file.zip"); It works but gives me empty .zip file, anyway its for not apache2 server..

File has only few KB

Anyone know how to fix it ?

EDIT: It says in error.log: The given path was above the root path: xsendfile: unable to find file: /protected/file.zip

I set XSendFilePath /protected and the erro now is: (2)No such a file or directory: xsendfile cannot open file: /protected/file.zip,referer: http://domain.com/file/

  • 写回答

1条回答 默认 最新

  • doutuan8887 2012-07-10 13:52
    关注

    Look up the mod xsendfile documentation. You have to set the directories that its allowed to serve files from. If you've done that, then I would suspect some other issue, such as symlinks not being served, etc....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)