我有以下代码从文件夹中读取image.jpg,但是尽管添加了(假设的)正确的标头并且在IIS上设置了正确的MIME,它会显示代码而不是显示图像。
<?php
// open the file in a binary mode
$name = 'image.jpg';
$fp = fopen($name, 'rb');
// send the right headers
header("Content-Type: image/jpeg");
header("Content-Length: " . filesize($name));
// dump the picture and stop the script
fpassthru($fp);
exit;
?>
显示代码:
JFIFHHCC“