0
還有很多提到x-sendfile沒有返回文件的其他問題,但它們都沒有能夠解決我的問題。apache x-sendfile找不到文件
我從網站的公共根目錄以外的目錄提供圖像,並希望能夠以儘可能少的開銷將這些圖像傳遞給用戶,所以我想避免使用readfile()來處理它們。因此我試圖使用x-sendfile。
我的開發環境由64位Windows上的XAMPP(apache和php)安裝組成。我正在使用mod_xsendfile.so的64位Windows二進制文件,該文件似乎根據phpinfo()正確加載。
我在想這可能是一個圍繞大小寫敏感或反斜槓/轉發的問題,但似乎並非如此。
如果我將錯誤日誌中的路徑複製並粘貼到映像加載的資源管理器窗口中,該文件確實存在。此外,我已經使用file_exists和文件大小來驗證在PHP路徑。
httpd.conf中設置:
LoadModule xsendfile_module modules/mod_xsendfile.so
XSendFile On
XSendFilePath "c:/images-store/"
PHP代碼
header('Content-Type: image/jpeg');
header('X-Sendfile: c:/image-store/5cca6ef24ae46c4346c24846ee3e5521213562ef-thumb.jpg');
錯誤日誌條目
[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
任何見解,我怎麼能得到這些文件送達會大。