note 42852 added to function.imagecreatefrompng

From: Date: Tue, 01 Jun 2004 02:57:48 +0000
Subject: note 42852 added to function.imagecreatefrompng
Groups: php.notes 
Request: Send a blank email to php-notes+get-70379@lists.php.net to get a copy of this message
This is a another case of someone (IE) thinking they know better than you what you want. If you are of a mind to generate a complicated (read takes a long time) image incrementally, you might do it by having an IFRAME which calls to the image generating PHP script. That munches for a bit, saves the file, returns to the client (remembering we're in the iframe so the user doesn't see all this) (with appropriate state information in <input type=hidden ...> fields) which kicks off an <body onLoad='docInit()' ...> whose purpose is to set the src attribute of the png image to the saved file (so the user sees the changes), and then resubmit the iframe (the image isn't in the iframe so the iframe can be hidden) to repeat the process. Very nifty. However, IE 6 has decided that it is far better to use a cached version of an image even on a local machine, where it can readily see that it changed, rather than to go to the source. And, since it's a file, you can't so easily set headers on it. This means that your incremental updates may not show any updates. I solved this by (1) having Apache rewrite every .png request to a single .php file: RewriteRule ^(.*).png$ pngPassThru.php?file=$1.png [QSA,L,NC] (2) All pngPassThru.php does is to return the .png file with "don't cache me" headers. Avoid leading/trailing spaces in pngPassThru.php. The headers might be simplified - I've collected them from various sources and am not sure which ones could be eliminated. But this is working for me on IE 6: <?php header("Content-type: image/png"); 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"); $file=@$_GET['file']; $size= filesize($file); header("Content-Length: $size bytes"); readfile($file); ?> Csaba Gabor ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefrompng.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42852 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42852&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42852&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70379) next »