I am using “xampp-win32-1.7.1-installer” as server & Dreamwaver cs5 for coding. I want to enable php GD support. I saw the
phpinfo();
there is showing GD support is enable. But it still doesn’t work. I don’t know why it doesn’t work? What should I do?
Well, actually i want to create an image with php. There is text box & submit button. When i give an input & press submit, it appears in that image box. It can do in many others platform but this time i want to do it in php.
here is my code :
<?php
header("Content-type: image/jpeg");
?>
<form action="Creating_Images_with_PHP.php" method="get">
<input type="text" name="name" />
<input type="submit" value="Enter" />
</form>
<?php
$name = $_GET['name'];
$message = "Welcome to php academy, $name";
$length = strlen($message) * 9.3;
$image = imagecreate($length, 20);
$background = imagecolorallocate($image, 0, 0, 0);
$foreground = imagecolorallocate($image, 255, 255, 255);
imagestring($image, 5,5,1, $message, $foreground);
imagejpeg($image)
?>
and the showing error is :
"The image http://localhost/www/...blaa blaa blaa cannot be displayed because it contains errors."
your outputting the image as raw data. Thats ok, but your also sending out html code, thus corrupting your image.
To start with you need to separate the two, and this should produce what you need assuming your existing php code works.
something.html
Creating_Images_with_PHP.php
Once you’ve tested that you can work on making the script and html code live in the same file. You do this by checking the request information from your name field: