我已在生产服务器和本地wamp安装上测试了此代码。在我的本地安装上,它返回bool(true)
并创建一个图像,但在我的生产服务器上,它返回bool(false)
,并且没有创建新图像:
error_reporting(E_ALL);
$animage = imagecreate (200, 200);
$red = imagecolorallocate ($animage, 255, 0, 0);
imagerectangle ($animage, 0, 0, 200, 200, $red);
$black = imagecolorallocate ($animage, 0, 0, 0);
imagefilledellipse($animage, 100, 100, 150, 150, $black);
$white = imagecolorallocate ($animage, 255, 255, 255);
imagestring($animage, 5, 48, 95, "Hello World!", $white);
$save = 'uploads/a.png';
chmod($save,0755);
var_dump(imagepng($animage, $save));
imagedestroy($animage);