Jump to content

HTTP header change and output buffering


abdfahim

Recommended Posts

Dears,

 

I want to output an image by imagepng function in between some texts. For that I used the below codes

// Above this i set image properties by GD functions in $img variable

ob_start();
echo "Text 1";

header("Content-type:image/png");
imagepng($img);
imagedestroy($img);

header("Content-type:text/html");
echo "Text 2";

ob_end_flush();

 

But unfortunately the image is not visible, rather it turns into some abnormal characters. But if I get rid of the texts (like below), image is printed perfectly.

 

// Above this i set image properties by GD functions in $img variable

ob_start();

header("Content-type:image/png");
imagepng($img);
imagedestroy($img);

ob_end_flush();

 

Anybody please help.

Link to comment
https://forums.phpfreaks.com/topic/251571-http-header-change-and-output-buffering/
Share on other sites

You must put a HTML <img src="url_that_produces_image_goes_here" alt=""> tag on your page for each image.

 

The url_that_produces_image_goes_here is the URL to your .php script that outputs the content-type header followed by the image data.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.