/    Sign up×
Community /Pin to ProfileBookmark

Graphics manipulation in PHP – Problems with IE refreshing

Hi, I’m building a program in PHP which allows the user to add graphics to a background. The user uploads multiple images and presses the submit button. Upon submit, the screen refreshes, but the image does not change. After the page updates, I can hit the refresh button on the browser menu, or press f5. The changes are then displayed. However, I would like the changes to be displayed after the user presses the submit button. It works great in FireFox, but it seems that IE is doing the original refresh before the data is processed, or it’s trying to pull old cached values.

I’ve tried the <meta http-equiv=”refresh” content=”1″>, but it keeps requesting the page over and over. So, I put the image in it’s own iframe. However, it continually makes requests to the server for the image and it displays that loading status bar at the bottom of the screen over and over.

I tried creating a loop and then setting the content value as an incrementing variable. Like this:

for($i=0; $i<=100; $i+50)
{
<meta http-equiv=”refresh” content=”$i”>
}

However, what I realized is that $i will not increment because the meta tag is itself an eternal loop. If I put a print statement after it within the for loop, it will not print, because it never reaches it. It just keeps looping forever within the meta tag. I wish there was some break statement that you could put in the meta tag. For instance, wouldn’t it be great if you could do something like <meta http-equiv=”refresh” content=”1″ stop =”5″> so it would stop looping after 5 refreshes (or whatever you want). Of course this statement is not valid. However, does anyone know of any value I can put in the meta tag that would give me the effect I need? Oh, and I don’t want to use java script.

I’ve also tried to redirect the image to the frame: Header(Location: $image_location); However, the same thing happens and I can’t seem to find a way to specifiy an image size on redirects.

It’s not a design issue, I’ve tried putting the iframe after all the data has been processed, just to see if maybe I just called the image too soon. I believe it is a problem with IE since Fire Fox works perfectly.

Also, there is a possibilty that it has to do with cached images. But, I don’t know how to delete a single cached image before calling the image. The program works within a session, so I don’t want to delete the entire cache.

Does anyone have any code or pointers. Or have you also experienced this with IE? Thanks for you help.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsNov 04.2005 — Redirect to a page and then add one to a GET variable, and then check it the next time to see if you should write the redirection.
Copy linkTweet thisAlerts:
@NogDogNov 04.2005 — You could try adding this at the top of the file (from an example at http://us2.php.net/session_cache_expire ):
[code=php]
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
[/code]
Copy linkTweet thisAlerts:
@sitehatcheryauthorNov 04.2005 — I don't have the code in front of me right now, but I think I may be able to accomplish this first displaying the image and then calling the image again with: Header('Location: $image_file"); in the the page called by the iframe tag. However, the problem here is that I don't know a way to specify the size of the image from the header.

Is there any reason why this wouldn't work? And if so, how would I specify the size of the image displayed with the header? Thanks!
Copy linkTweet thisAlerts:
@sitehatcheryauthorNov 05.2005 — Ok, so I tried my idea and it didn't work.

I had an iframe tag that called preview.php which displayed an image: <img src=image.jpg width="200" height="200">.

My idea was to display a header function just below this image tag: Header("Location: preview2.php"); preview2.php would just have an identical image tag: <img src=image.jpg width="200" height="200">.

The idea being that it would display the original image and then refresh it once. However, it would not work. In fact, even though the header function was below the image tag on preview.php, the image tag was not read at all. I tested this by calling sleep(5) just before calling the second identical image. It was nothing but a blank frame for 5 seconds before the image was shown. This shows that if there is a header function, no other data on the page is processed. I even tried putting the header function within an if/then statement to keep it from being called. It was called anyway. So, that idea is out the window.

I tried the following code on the top and in the head tag of both the page that had the iframe tag and the preview.php page which contained the image, as suggested by NogDog:

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache");

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

I also played with SpectreReturns idea about setting a variable as a trigger to determine whether or not to redirect based on the variable value.

I was hoping to come back to declare my victory, but the quest continues. Actually, I kind of got it working today. There is an multiple image file upload page that goes through a series of validations before the file is accepted. Errors are displayed if one of several possible problems are encountered. If I place the meta refresh tag within the bit of code that accepts the file it runs only once. This is because once the page tries to refresh, the second time around it thinks that no files were uploaded at all. So, the second time around, the meta refresh tag is not reached within the code that accepts the file.

But, this is not how I want to do it because I need to display the errors correctly. Hopefully, though, knowing this will spark the creative genius of a fellow programmer.

Any brainstorms? Thanks!
Copy linkTweet thisAlerts:
@sitehatcheryauthorNov 09.2005 — So far, I'm still stuck on this. I've re-arranged all my pages and have tried everything I can think of. I'm using ImageMagic to compile text and other images to a background image. The user can upload multiple files and enter text in multiple fields. The user clicks on the submit button and the images and text are written to the background image. However, after the page loads, I have to hit the refresh button to see the changes. There seems to be no way to simply refresh one time.
Copy linkTweet thisAlerts:
@sitehatcheryauthorNov 16.2005 — Bokeh solved my problem on http://www.webdeveloper.com/forum/showthread.php?t=84747. It's so simple, I can't believe I haven't found another reference for this. But in case anyone is wondering, you can find the answer there.
×

Success!

Help @sitehatchery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...