PHP中的图像读取显示代码而不是图像

时间:2015-07-23 14:36:08

标签: php fopen

我有以下代码从文件夹中读取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“

0 个答案:

没有答案
相关问题