我在PHP中创建的Web浏览器上没有显示图像 [英] Image not showing on Web Browser which I created in PHP

查看:131
本文介绍了我在PHP中创建的Web浏览器上没有显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XAMPP来提供php页面。我所有的PHP代码运行正常。但是当我使用以下php代码创建图像时:



I am using XAMPP to serve php pages. All my PHP codes are running fine. But when I create image using the following php code :

<!DOCTYPE html>
<html>

<head>

</head>

<body>

<?php

$myImage = imagecreate( 200, 100 );

$myGray = imagecolorallocate( $myImage, 204, 204, 204 );

$myBlack = imagecolorallocate( $myImage, 0, 0, 0 );

imageline( $myImage, 15, 35, 120, 60, $myBlack );

header( "Content-type: image/png" );

imagepng( $myImage );

imagedestroy( $myImage );

?>

</body>
</html>





并且运行页面Google Chrome和Firefox仅显示图像占位符,IE8显示以下二进制代码:



<!DOCTYPE html>

< html>



< head>



< / head>



< body>



‰PNG




$ b $bIHDRÈd??ùHíH?PLTEÌÌÌ33dMIDATH‰c` ??£? ?Àx§

N?f *k²Ã)Ãø§?•5}À?? ?? ?? ??pJUàa§²|?œ2ÔŽw<š?pj ?? ,q0>

†; ???
$ b $buTBúŸIEND®B`,

< / body>

< / html>



我检查了php.ini文件并从extension = php_gd2.dll之前删除了;。仍然无法正常工作。请帮助。



and run the page the Google Chrome and Firefox show just an image place holder and IE8 shows the following binary code:

<!DOCTYPE html>
<html>

<head>

</head>

<body>

‰PNG


IHDRÈdùHíHPLTEÌÌÌÓ33dMIDATH‰c`£` Àx§"
Nf*k²Ã)Ãø§"•5}À)ŏS†ÚšpJUà"a§²¦œ2ÔŽw<špj‚q0>
†;
uTBúŸIEND®B`‚
</body>
</html>

I have checked php.ini file and have removed ';" from before "extension=php_gd2.dll". Still not working. Please help.

推荐答案

myImage = imagecreate( 200, 100 );

myImage = imagecreate( 200, 100 );


myGray = imagecolorallocate(
myGray = imagecolorallocate(


myImage, 204, 204, 204 < span class =code-summarycomment>);

myImage, 204, 204, 204 );


这篇关于我在PHP中创建的Web浏览器上没有显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆