note 54443 added to ref.image

From: Date: Mon, 04 Jul 2005 22:03:09 +0000
Subject: note 54443 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-91441@lists.php.net to get a copy of this message
As many people found any PhP made image working standalone but not in an img tag, I 'll explain how I solved it. //Part1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); //Part2 header('Content-Length: '.filesize($pic)); header('Content-type: image/jpeg'); readfile($pic); Just some header work, the first part makes the image non-cacheable and the second one ensures the browser gets all the needed information. As I did not need it I did not yet find a way to get the filesize of a GD made image, so I assume you save it to disk, get the filesize and read it again. I hope I just helped you out, and saved you from 2 hours of finding out why the stupid PhP has to add data at the beginning of your image. It may look trivial, the Content-Length is not given by default! AmX ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54443 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54443&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54443&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91441) next »