note 54443 deleted from ref.image by tularis
| From: | tularis@php.net | Date: | Sun, 29 Jun 2008 21:06:35 +0000 |
| Subject: | note 54443 deleted from ref.image by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140940@lists.php.net to get a copy of this message | ||
Note Submitter: AmX
----
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