note 107069 added to book.image
| From: | herbert dot walde at googlemail dot com | Date: | Wed, 04 Jan 2012 19:41:15 +0000 |
| Subject: | note 107069 added to book.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185362@lists.php.net to get a copy of this message | ||
In case your script is using output-buffering-functions somewhere, then you have to clear the buffer
first ( with ob_clear() ), before outputting an image with a function like imagepng().
And you should make sure that no buffer will get send after outputing an image by using the
ob_end_flush()-function.
Furthermore you should check if a buffer has already been flushed somewhere before. This can be done
using the headers_sent()-function.
Here is the full solution:
==============
if(headers_sent()){
die('Headers have been send somewhere within my script');
}
ob_clean(); //Clears the buffer
header('Content-type: image/png');
imagepng($img, NULL, 0, NULL);
ob_end_flush(); //Now we send the header and image plus we make sure that nothing will get send from
now on (including possible shutdown-functions and __destruct()-methods) till the end of
page-execution
----
Server IP: 217.160.235.204
Probable Submitter: 88.67.241.214
----
Manual Page -- http://www.php.net/manual/en/book.image.php
Edit -- https://master.php.net/note/edit/107069
Del: integrated -- https://master.php.net/note/delete/107069/integrated
Del: useless -- https://master.php.net/note/delete/107069/useless
Del: bad code -- https://master.php.net/note/delete/107069/bad+code
Del: spam -- https://master.php.net/note/delete/107069/spam
Del: non-english -- https://master.php.net/note/delete/107069/non-english
Del: in docs -- https://master.php.net/note/delete/107069/in+docs
Del: other reasons-- https://master.php.net/note/delete/107069
Reject -- https://master.php.net/note/reject/107069
Search -- https://master.php.net/manage/user-notes.php