PHP可以';t使用X-SendFile和jpeg标题显示图像

PHP可以';t使用X-SendFile和jpeg标题显示图像,php,apache,.htaccess,http-headers,x-sendfile,Php,Apache,.htaccess,Http Headers,X Sendfile,由于某些原因,我无法正确显示图像,它会抛出错误,而不会告诉我出了什么问题,有什么想法吗 代码 $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

由于某些原因,我无法正确显示图像,它会抛出错误,而不会告诉我出了什么问题,有什么想法吗

代码

$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 );
标题

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

你确定你的档案在那里吗

我看到
内容长度:0
。我怀疑你是否想发送空文件


尝试删除
标题
s输出,并将其替换为
echo
s,以查看scrit失败的位置。

上述代码确实有效,是x-sendfile在apache中未正确配置

无需修复它,结果是x-sendfile由于apache配置中指定的目录不正确而未加载。这确实有效,原来x-sendfile的配置不正确。