RE: [PHP] auto-refresh dynamic images

From: Date: Thu, 14 Sep 2000 13:31:55 +0000
Subject: RE: [PHP] auto-refresh dynamic images
Groups: php.general 
Request: Send a blank email to php-general+get-16773@lists.php.net to get a copy of this message
I have a pretty simple solution for you on the first one. Attach a random number to the end of the picture's url. I have a webcam that uses the same image name for single frame captures. If you refresh the page it will refresh the picture (do to my no cache settings) however it also reloads everything else on the page there by wasting bandwidth for documents which do not need to be reloaded. My solution for getting the image to reload only is create a javascript function to reload the picture only. The problem I encounted was that once a file is loaded on page, any subsequent call to a filename with the same name will load the same picture again even if the image has changed in data. This is due to how a browser creates an array of image names when a page is loaded. So I need a way to make each image name unique with out actually making the name unique. Here is how I do it: 1) I create a random number in JS. 2) I attach the random number to the end of the picture name. (http://mydomain.com/webcam.jpg?823754586823) imgnum=Math.random() * 100000; function refresh_cam(imgName) { imgnum=imgnum+1; if (version == "n3") { imgNew = 'http://mydomain.com/webcam.jpg?' + imgnum ; } document[imgName].src = imgNew ; } <IMG NAME="cam" HEIGHT=240 WIDTH=320 SRC="webcam.jpg"> <A HREF="javascript:refresh_cam('cam')">refresh image</a> This is strictly a JS solution... But if you were to do something like it in PHP it wouldn't be much different from hitting the refresh button. Also another solution for your reloading issue would be to create a seperate window with just the images in them and then have the page meta refresh every 5 minutes... Then just tack on a random number in PHP and you would be okay... Same rules apply... HTH Tom Walsh http://www.designgeek.com > Hi, > > I am generating some jpegs dynamically from a weatherstation > program and > FTPing them to my webserver every 5 minutes. How do I get the > PHP3 page to > force the images to be uploaded to the client's browser every > time the page > is reviewed instead of getting the out of date images from cache? > > Also, how do I get the page to refresh at a particular > interval AND refresh > the jpegs? For instance if someone wants to leave thee page > displayed ffor a > while and just have it refresh every 5 minutes to show the > new images and > the coresponding change in weather? > > <METAs...> work only for the text, NOT the jpegs. Will using > the header() > function work for the images as well as text? > > Any help appreciated. > > Thanks,

« previous php.general (#16773) next »