显示本地主机但不在服务器上的PHP GD图像
我一直在MAMP(phpversion5.4.10)上使用localhost。我将完全相同的文件上传到我购买的running LAMP服务器上(PHP版本5.4.15-1~lucid+1)。我打开了文件localhost,加载的图像正确无误。我上传到服务器上的确切文件,我得到了破碎的图像。我的代码:显示本地主机但不在服务器上的PHP GD图像,php,image,gd,Php,Image,Gd,我一直在MAMP(phpversion5.4.10)上使用localhost。我将完全相同的文件上传到我购买的running LAMP服务器上(PHP版本5.4.15-1~lucid+1)。我打开了文件localhost,加载的图像正确无误。我上传到服务器上的确切文件,我得到了破碎的图像。我的代码: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); require_once('query.class.php'
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('query.class.php');
$Server = new MinecraftServerStatus($IP = '69.65.42.155', $Port = 30465, $Timeout = 1);
header('content-type: image/png');
$image = imagecreatefrompng('http://192.34.58.24/cfgd/images/o_image1.png');
$dark_grey = imagecolorallocate($image, 102, 102, 102);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocate($image, 255, 0, 0);
$green = imagecolorallocate($image, 0, 255, 0);
$font_path = 'Brixton';
$title = 'Knightsrp';
if($Port != 25565){
$dip = $IP.':'.$Port;
}
else{
$dip = $IP;
}
if($Server->Get('online')){
$status = 'Online';
$players = $Server->Get('numplayers').' / '.$Server->Get('maxplayers');
}
else{
$status = 'Offline';
}
imagettftext($image, 30, 0, 10, 35, $white, $font_path, $title);
if($status == 'Online'){imagettftext($image, 20, 0, 5, 87, $green, $font_path, $status);}else{imagettftext($image, 20, 0, 5, 87, $red, $font_path, $status);}
if($status == 'Online'){imagettftext($image, 20, 0, 550, 87, $white, $font_path, $players);}
imagettftext($image, 20, 0, 350, 20, $white, $font_path, $dip);
imagepng($image);
imagedestroy($image);
?>
您可以在这里找到我使用的php类:我添加了
putenv('GDFONTPATH=' . realpath('.'));
以前
imagettftext($image, 30, 0, 10, 35, $white, $font_path, $title);
您的远程服务器上是否安装了GD?很抱歉忘记添加,是的,我的服务器和本地主机上都安装了GD。是否正确?服务器上是否存在该字体?在phpinfo中,
udp
是否注册为流套接字传输协议?
?错误,不确定您的意思。您可以在这里检查phpInfo()。