0
我一直在MAMP(PHP版本5.4.10)上工作localhost。我將EXACT文件上傳到我購買的運行LAMP的服務器上(PHP版本5.4.15-1〜lucid + 1)。我打開文件localhost和圖像加載正確和正確。我將確切的文件上傳到服務器上,並得到了破碎的圖像。我的代碼:顯示本地主機但不在服務器上的PHP GD圖像
<?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類我在這裏使用:https://github.com/NoxNebula/Minecraft-Server-Status
之前爲Gd安裝在遠程服務器上? – sebastian
對不起,忘了補充一點,是我的服務器和本地主機都安裝了GD。 – OPatel
'$ font_path'是否正確?字體是否存在於服務器上? – sebastian