A simple PHP drawing problem 、、、
I write the following code on the PHP page:
Header (' Content-type:text/jpeg '); This place can be executed correctly if it is annotated.
$im =imagecreatetruecolor (200,200);
Imagepng ($im);
?>
If the above place is not annotated, you cannot draw the picture. The browser also prompts to download (download is not a picture) Ah, or open (after opening is garbled).
Question: Does drawing have to have this header () to specify the type? Does it have something to do with PHP.ini's profile? Or the other reason, I can't think of it.
------Solution--------------------
You output the browser, you have to tell it, you want to export to others what kind of things??
Like HTML and the like is text/html ....
------Solution--------------------
I do not understand a bit, comment out the MIME type should be text/html, how to display the picture?
In addition, you output the PNG format, but the header sends the JPEG format. Let's see.
------Solution--------------------
Header (' content-type:image/png '); Note: image instead of text
$im =imagecreatetruecolor (200,200);
Imagepng ($im);
Red to match
The header of the type declaration is required, depending on the type of browser
------Solution--------------------
Header (' Content-type:image/jpeg '); Image is the specified picture type.
------Solution--------------------
Example 1. Create a new GD image stream and output the image
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.