note 80533 deleted from function.imagejpeg by cmb

From: Date: Sun, 02 Oct 2016 07:53:20 +0000
Subject: note 80533 deleted from function.imagejpeg by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206719@lists.php.net to get a copy of this message
Note Submitter: james [at] bellisinasce.it ---- When using ImageJpeg ($img, "", $qlty) or any other Image*() command, with direct output to browser, BE ABSOLUTELY CERTAIN that your php file does not contain any \r, \n, or white spaces before the <? and after the ?> signs. This should always kept in mind, not only for the file you are executing BUT ALSO FOR ALL THE INCLUDES called during the file execution! I got totally crazy about this, for a whole weekend :( My php editor did not correctly display a \n sign, as I was locally using a different charset/OS. example <? include ("/usr/www.example.com/inc/function.inc.php"); include ("/usr/www.example.com/inc/function.common.php"); connect_db0 (); $admin_cookie = ckadmin_cookie (); ... $img = file_get_contents ($path.$_GET['src']); $im = imagecreatefromstring ($img); header ("Content-Type: image/jpeg"); imageJPEG ($im); imageDestroy ($im); ... ?> If any of the included files, for any reason, prints an error message (or simply a warning) or has any white spaces/return/new line chars before "<?" or after the ">?" signs, the result will be a broken image! Even looking inside the defective image, it will be quite difficult to notice the unwanted characters, especially if you are using something like the windows' notepad... X( If nothing is found, with the file/php editors, and you are not sure about your charset compatibility, I suggest to try to edit directly the files on the server, if possible, and search for all unwanted chars. ;)

« previous php.notes (#206719) next »