【问题标题】:XSendFile Apache2 mod has zero bytesXSendFile Apache2 mod 的字节数为零
【发布时间】:2015-02-21 11:36:58
【问题描述】:

我的代码,路径正确,内容长度正确

header("X-Sendfile: " . $savePath); 
header('Content-Length: ' . filesize($savePath));
header("Content-type: $type");
header('Content-Disposition: attachment; filename="' . basename($localFilename) . '"');

exit();

我的 .htaccess

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

这总是会导致下载大小为零的文件。

该文件确实存在并且在正确的位置。使用curl -I 向我展示了以下内容,这似乎很好。但文件仍然是零字节。

HTTP/1.1 200 OK
Date: Sat, 21 Feb 2015 11:35:37 GMT
Server: Apache/2.2.29 (Amazon)
X-Powered-By: PHP/5.3.29
X-Sendfile: /var/www/html/cache/72b08eb707bb5eab58d8e5d7d9b21bb8.jpeg
Content-Length: 10004
Content-Disposition: attachment; filename="72b08eb707bb5eab58d8e5d7d9b21bb8.jpeg"
Connection: close
Content-Type: image/jpeg

我做错了什么?

【问题讨论】:

    标签: php apache x-sendfile


    【解决方案1】:

    原来你需要使用

    XSendFile on
    

    在您的主要 Apache2 conf 中,否则它将无法在任何地方工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多