dongming4994 2016-08-18 23:54
浏览 38

apache x-sendfile找不到文件

There are lots of other questions referring to x-sendfile not returning files, but none of them appear to be able to fix my issue.

I am serving images from a directory outside the public root of the site and want to be able to deliver those images to the user with as little overhead as possible, so I want to avoid processing them with readfile(). Hence I am trying to use x-sendfile.

My development environment consists of a XAMPP (apache and php) installation on a 64bit windows. I'm using the 64bit windows binary of mod_xsendfile.so, which appears to be loaded correctly according to phpinfo().

I was thinking it could be a problem around case-sensitivity or backslash/forwardslash but this doesn't seem to be the case.

The file does exist, if I copy the path out of the error log and paste it into an explorer window the image loads. Also I have used file_exists and filesize to verify the path in php.

httpd.conf setup:

LoadModule xsendfile_module modules/mod_xsendfile.so
XSendFile On
XSendFilePath "c:/images-store/"

PHP code

header('Content-Type: image/jpeg');
header('X-Sendfile: c:/image-store/5cca6ef24ae46c4346c24846ee3e5521213562ef-thumb.jpg');

Error log entry

[pid 3208:tid 1900] (20023)The given path was above the root path: [client 127.0.0.1:57477] xsendfile: unable to find file: c:/image-store/5cca6ef24ae46c4346c24846ee3e5521213562ef-thumb.jpg

Any insights as to how I can get these files to be served would be great.

  • 写回答

1条回答 默认 最新

  • douduidui1046 2016-08-19 00:27
    关注

    Turns out it was case sensitivity. The c in the path needed to be a capital C.

    XSendFilePath C:/images-store/
    

    I should probably switch back to linux for my development...

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line