954,141 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Delete temporary file on users machine?

Quick question here. I wanted a way to quickly change the URL of an image that is place on my page, so I came up with the following little script:

<?php

echo "Status: $status";
if ($status == 'Online'){
rename('status.bmp', 'offline.bmp');
rename('online.bmp', 'status.bmp');
}
elseif ($status == 'Offline'){
rename('status.bmp', 'online.bmp');
rename('offline.bmp', 'status.bmp');
}

echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=status.htm\">";

?>


I pass the $status variable from a link before this page.

It works the first time. Actually it works all the time, but after the first time, the old image is left in the users temp directory, so the image doesn't change until they delete it from their temporary internet files. In firefox, it works ok if you just refresh the page, but in IE, it doesn't work until you delete the temp files. is there another way i can go about this?

Let's assume that I can't change the code on the page that is calling the image. That's why I need to change the name of the file on the server.

Thanks.

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 
<?php
header('Cache-Control: no-cache, no-store, must-revalidate'); //HTTP/1.1
header('Expires: Sun, 01 Jul 2005 00:00:00 GMT');
header('Pragma: no-cache'); //HTTP/1.0
?>


Use the above code to tell the browser not to cache the page.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

So you're saying that code needs to go on the page that I'm displaying the image on? Little problem with that, can't use php. Only html. I can run the php script from anywhere, the page that's calling the image hast to be plain html. So can I implement that solution without the php?

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

This might help.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Ah, I see, instead of sending the headers via php, put them where they ought to be in the first place? Thanks for not laughing in my face. That should do it, I'll give that a try.

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

yep.. :)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Well, I tried putting this in the tags of the page:

As well as this:

And it's still having the same problem.

Any ideas? Sorry, I guess this is now turning into an HTML discussion, of which I am even less experienced with than PHP, but that's another story!

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

hmm.. well, i am kinda lost too. But, If you can use javascript, try location.href="status.html". Some other alternatives (?). Try
or, you can redirect to another page, say, page1.html and then, redirect back to status.html. :icon_mad:

If no-cache doesn't work, then i don't know what will ?

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You