Php header ('Content-Type: image / png')

I have a problem with the header in php.

I have this simple code.

<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
      or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>

I think it should work fine, but it is not. There is no error, and a short image icon appears in the upper left corner of my browser.

I think the problem is with the header.

other useful information: PHP version 5.3.10-1ubuntu3.9 GD support GD version 2.0 FreeType support included FreeType Communication with freetype FreeType Version 2.4.8

UPDATE In IE, even if I have a header, I got a bunch of data ...

+3
source share
3 answers

“Small split image” means the image is invalid. Since your generation code seems correct, you should have a PHP error.

header, , . -, PNG, , PNG, header, . PHP.

+2

:

header ('Content-type: image/png');

header ('Content-type: image/png');

. ANSI.

0

Your problem is the folder path. Create a folder for the image.

e.g. .: barla

After changing the title bar ("Content-type: barla / image / png");

Your problem will solve

-1
source

All Articles