warewolfe Posted September 21, 2006 Share Posted September 21, 2006 Hi, I have a same-page form-display script that calls a function to generate a jpg. If the form hasn't been filled in it shows a default .jpg. The trouble is that when the submit button is pushed and the new .jpg is created the page itself doesn't change to show the new image. Is there a php solution or do I have to use javascript? Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 21, 2006 Share Posted September 21, 2006 The problem is that cos the image is the same name, then when the users machine reads the data, it see's it has the image on the users machineSimple solution, is to stop the cachethis is HTM META tag, place in the head of your wesbite[code]<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><META HTTP-EQUIV="Expires" CONTENT="-1">[/code] Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 21, 2006 Author Share Posted September 21, 2006 Thanks for the reply and it was a help, but default.jpg and the target.jpg did have different names. (Which was the bit that weirded me out). Your code does make the browser distinguish between default.jpg and target.jpg but if I update target.jpg with the same form it takes a manual refresh for the page to notice the difference. Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 21, 2006 Share Posted September 21, 2006 PHP is Server Side Coding, Nothing will change without a Page RefreshTry Client side Coding, such as Javascript Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 21, 2006 Author Share Posted September 21, 2006 Got that, just trying to see if there was a non-javascript solution given that there is a form action going on and the page is renewing itself at least partially. I'm trying to understand why the page will not fully renew itself as the Headers for the target.jpg change on submit, but not the image itself. Even with the caching turned off. Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 21, 2006 Author Share Posted September 21, 2006 Actually above solution works for firefox, now guessing it's a case of Internet Explorer just being Internet Explorer. Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 21, 2006 Share Posted September 21, 2006 There is a setting in IE, which says if it should grab the images again, or use the system imagesThis is a nightmare, when working with GD Lib, as if your cropping / resizing images, it uses the local file, not the server fileTo change this (for note)On the File, Edit, View...Click Tools -> Internet OptionsThen in the middle of the screen says, Temporary Internet Files,and a button for SettingsClick SettingsThen you should have some radio buttons at the top,My Default, this is set to Automatically.Change this toEvery visit to every pageSolves the problem every timeBut unless you want to tell your users to do this, I dont know Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 21, 2006 Share Posted September 21, 2006 If you are able to name an image 'default.jpg?random_number_of_some_sort' then the browser will think it is different from any other 'default.jpg' in the cache and load a fresh version. Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 21, 2006 Author Share Posted September 21, 2006 Thanks for the help, I'm going to autoincrement the target image's name with "target$var.jpg" to get the same effect as a fresh name but still be able to show the image within an html tag. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.