Hi guys,
I am having an issue with generating images using PHP.
When I include the PHP file(ex. graph.php), which generates the PNG image, in my current html file, it gives an error saying "Headers already sent". It then displays the image as ASCII text. This happens only when the include statement is preceeded by any html tags.
if I remove the following statement from graph.php, it eliminates the error but still shows the image as ASCII text: 'header("Content-type: image/$this->img_format");'
How do i make it work smoothly
I am using the jpgraph 1.7 class library to generate the png images.
Cheers
Kapil Karekar
----- Original Message ----- From: kapil_karekar@vsnl.net To: linuxers@mm.ilug-bom.org.in Sent: Tuesday, September 03, 2002 9:38 PM Subject: [ILUG-BOM] Image Support with PHP
Hi guys,
I am having an issue with generating images using PHP.
When I include the PHP file(ex. graph.php), which generates the PNG image, in my current html file, it gives an error saying "Headers already sent". It then displays the image as ASCII text. This happens only when the include statement is preceeded by any html tags.
You can't send html tags before displaying an image if you're generating it in that script.
if I remove the following statement from graph.php, it eliminates the error but still shows the image as ASCII text: 'header("Content-type: image/$this->img_format");'
well donno what you meant by above. The header should be
Content-type: image/png
If it's not you probably have some configuration problem. Which could be too many things.
How do i make it work smoothly
I am using the jpgraph 1.7 class library to generate the png images.
Great class!
- cnb
Cheers
Kapil Karekar
On Tue, 3 Sep 2002 kapil_karekar@vsnl.net wrote:
Please fix your line length.
When I include the PHP file(ex. graph.php), which generates the PNG image, in my current html file, it gives an error saying "Headers already sent". It then displays the image as ASCII text. This happens only when the include statement is preceeded by any html tags.
Umm, you can't send your html and image as part of the same data stream. They have to be two separate data streams, in response to two separate HTTP requests.
ie, user requests page, you send:
Content-type: text/html
<html>....
<img src="script.php?send-image">
user requests script.php?send-image, you send:
Content-type: image/png
image data here
You're trying to send both in a single HTTP response.