1

My code, the paths are correct and the content length is correct

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

exit();

My .htaccess

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

This always results in a zero sized file download.

The file is definitely there and in the right place. Using curl -I shows me the following which appears to be fine. But the file is still zero bytes.

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

What have I done wrong?

1 Answer 1

3

So it turns out that you need to use

XSendFile on

In your main Apache2 conf otherwise it will not work anywhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.