图形没有显示在互联网上但在localhost上很好(php)

时间:2014-01-26 14:09:03

标签: php graphics

我最喜欢的网站,这是第一次写作。我在使用php写一个图像这个工作在我的本地主机上工作正常,但它不是在互联网上的wortking(000webhost)我已经谷歌搜索然后检查我的gd库是打开,我也设置权限所有但仍然没有显示图像。

<?php
session_start();
// File and new size
$filename = 'images/solar-kid.jpg';
if(isset($_POST['sub']))
{
    $txt=$_POST['txt'];
}

// Content type
header('Content-Type:image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = 350;
$newheight = 300;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

$white = imagecolorallocate($thumb, 255, 255, 255);
$grey = imagecolorallocate($thumb, 128, 128, 128);
$black = imagecolorallocate($thumb, 0, 0, 0);
imagefilledrectangle($thumb, 0, 0, 399, 29, $black);
imagefilledrectangle($thumb, 0, 270, 399, 299, $black);
$white = imagecolorallocate($thumb, 255, 255, 255);
$black = imagecolorallocate($thumb, 0, 0, 0);
$text = $txt;
$font = 'times.ttf';
imagettftext($thumb, 15, 0, 10, 20, $white, $font, $text);

// Output
imagejpeg($thumb);

?>

这是在网站Click here

上显示的结果

1 个答案:

答案 0 :(得分:0)

000webhost免费域名不支持我不知道为什么。我将它上传到另一台主机付费服务器,它就像一个魅力