Search code examples
phpapache.htaccesshttp-headersx-sendfile

PHP can't display image using X-SendFile and jpeg headers


For some reason I can't get the image to display properly, its chucking out errors not telling me what’s wrong, any ideas?

CODE

$finfo = finfo_open(FILEINFO_MIME_TYPE);
header("Content-type:   ".finfo_file($finfo, $filepath));
finfo_close($finfo);
header('Content-length: '.filesize($filepath));
header('Content-Disposition: inline; filename="'.$file.'"');
header('X-Sendfile: ' . $filepath );

HEADERS

HTTP/1.1 200 OK
Date: Mon, 07 Apr 2014 13:45:37 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.10
X-Sendfile: /path/image.jpg
Content-Length: 0
Content-Disposition: inline; filename="image.jpg"
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: image/jpeg

Solution

  • The above code did work, it was x-sendfile which was not configured properly in apache