Jump to content

Archived

This topic is now archived and is closed to further replies.

warewolfe

php generated forms not refreshing html img tag

Recommended Posts

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? 

Share this post


Link to post
Share on other sites
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 machine

Simple solution, is to stop the cache

this 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]

Share this post


Link to post
Share on other sites
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.
 

Share this post


Link to post
Share on other sites
PHP is Server Side Coding, Nothing will change without a Page Refresh
Try Client side Coding, such as Javascript

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Actually above solution works for firefox, now guessing it's a case of Internet Explorer just being Internet Explorer.

Share this post


Link to post
Share on other sites
There is a setting in IE, which says if it should grab the images again, or use the system images

This is a nightmare, when working with GD Lib, as if your cropping / resizing images, it uses the local file, not the server file

To change this (for note)
On the File, Edit, View...
Click
Tools -> Internet Options

Then in the middle of the screen says, Temporary Internet Files,
and a button for Settings
Click Settings

Then you should have some radio buttons at the top,
My Default, this is set to Automatically.
Change this to
Every visit to every page

Solves the problem every time
But unless you want to tell your users to do this, I dont know

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.