tonym Posted December 5, 2009 Share Posted December 5, 2009 I have this, which, apart from the header() is from the manual: <?php ob_start(); ?> <html> <body> <?php $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); header('Content-type: image/jpeg'); imagejpeg($im); imagedestroy($im); ?> </body> </html> <?php ob_end_flush(); ?> All I see in the browser is the url of the script. If I remove the header line, I see the binary source of the image. Any suggestions please? Tony Link to comment https://forums.phpfreaks.com/topic/184044-imagejpeg-and-header/ Share on other sites More sharing options...
trq Posted December 5, 2009 Share Posted December 5, 2009 Considering your trying to output an image you should remove all the html tags. Link to comment https://forums.phpfreaks.com/topic/184044-imagejpeg-and-header/#findComment-971679 Share on other sites More sharing options...
oni-kun Posted December 5, 2009 Share Posted December 5, 2009 Yep. You're telling PHP to output an image, yet you're telling it to feed HTML. The browser sees type "image/jpeg" Not text/html!, hense the double error. Link to comment https://forums.phpfreaks.com/topic/184044-imagejpeg-and-header/#findComment-971680 Share on other sites More sharing options...
tonym Posted December 5, 2009 Author Share Posted December 5, 2009 Thanks. Also needed to remove the flush buffer instruction. Tony Link to comment https://forums.phpfreaks.com/topic/184044-imagejpeg-and-header/#findComment-971681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.