abdfahim Posted November 21, 2011 Share Posted November 21, 2011 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 More sharing options...
abdfahim Posted November 21, 2011 Author Share Posted November 21, 2011 correction. stupid code, ofcourse I can't set 2 type of header content on the same page. But the main question still remains valid. How can I put that image in between text? Link to comment https://forums.phpfreaks.com/topic/251571-http-header-change-and-output-buffering/#findComment-1290161 Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2011 Share Posted November 21, 2011 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. Link to comment https://forums.phpfreaks.com/topic/251571-http-header-change-and-output-buffering/#findComment-1290162 Share on other sites More sharing options...
abdfahim Posted November 21, 2011 Author Share Posted November 21, 2011 thanks so much for the idea. I convert my code and it works fine. Link to comment https://forums.phpfreaks.com/topic/251571-http-header-change-and-output-buffering/#findComment-1290169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.