php用GD库生成的图片显示问题

来源:百度知道 编辑:UC知道 时间:2024/06/22 00:03:05
<?php
$width=200;
$height=200;

$img=imagecreatetruecolor($width,$height) or die("不支持GD图像处理");
imagepng($img);
imagedestroy($img);
?>
测试以上代码时为什么会提示下载图片,为什么不是在IE中直接显示该图片.

$width=200;
$height=200;

$img=imagecreatetruecolor($width,$height) or die("不支持GD图像处理");
Header("Content-type: image/png");
imagepng($img);
imagedestroy($img);

应该是加个HEADER就可以了,

HEADER 加类型是 图片的