benphp Posted August 7, 2008 Share Posted August 7, 2008 I have a page that has a user's image on it and a form with a file Browse textbox for uploading a new photo. Once you select the new photo, you click Upload, and it runs through an Upload.php file, then returns to this page. The image doesn't update unless I click F5 (refresh). Even if I put a link to the very same page, the cached image still displays. Any ideas? Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/ Share on other sites More sharing options...
Jesper Posted August 7, 2008 Share Posted August 7, 2008 Search google for: php refresh page. Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611174 Share on other sites More sharing options...
benphp Posted August 7, 2008 Author Share Posted August 7, 2008 Google. I wish I had thought of that. Thanks. Anyone else? Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611176 Share on other sites More sharing options...
deadlyp99 Posted August 8, 2008 Share Posted August 8, 2008 Use a get parameter instead of having upload.php re-direct to the image page. Try havingupload.php send to imagefile.php?p=refresh, which will then send the user to imagefile.php. Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611228 Share on other sites More sharing options...
benphp Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks! I'll give that a try. Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611267 Share on other sites More sharing options...
benphp Posted August 8, 2008 Author Share Posted August 8, 2008 Found the answer. It's simple, but makes no sense: <img src="yourimage.jpg?<?php echo time();?>" border="0" alt="" /> I've seen images listed like this before. Now I know what the ?var is for. Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611777 Share on other sites More sharing options...
papaface Posted August 8, 2008 Share Posted August 8, 2008 Found the answer. It's simple, but makes no sense: <img src="yourimage.jpg?<?php echo time();?>" border="0" alt="" /> I've seen images listed like this before. Now I know what the ?var is for. It gives the image a different name without actually renaming it, which prompts the browser to reload the image as it see's it as a different image. Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-611780 Share on other sites More sharing options...
grissom Posted September 11, 2008 Share Posted September 11, 2008 That answer came just in time for me. What a clever wheeze ! Thanks benphp and papaface. In my case, the whole statement was already in a php block, so it read like .. echo '<IMG SRC = "../photos/thumbnail/'.$photoCounter.'.jpg?'.time().'" BORDER="0" STYLE = "z-index:1" ALT = "'.$fileName.'">'.PHP_EOL; Link to comment https://forums.phpfreaks.com/topic/118703-how-to-force-a-refresh-new-image-doesnt-refresh-on-page-after-update/#findComment-638935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.