Delete temporary file on users machine?

Reply

Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Delete temporary file on users machine?

 
0
  #1
Dec 3rd, 2007
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:

  1. <?php
  2.  
  3. echo "Status: $status";
  4. if ($status == 'Online'){
  5. rename('status.bmp', 'offline.bmp');
  6. rename('online.bmp', 'status.bmp');
  7. }
  8. elseif ($status == 'Offline'){
  9. rename('status.bmp', 'online.bmp');
  10. rename('offline.bmp', 'status.bmp');
  11. }
  12.  
  13. echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=status.htm\">";
  14.  
  15. ?>

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.
Last edited by nathanpacker; Dec 3rd, 2007 at 6:30 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Delete temporary file on users machine?

 
0
  #2
Dec 3rd, 2007
  1. <?php
  2. header('Cache-Control: no-cache, no-store, must-revalidate'); //HTTP/1.1
  3. header('Expires: Sun, 01 Jul 2005 00:00:00 GMT');
  4. header('Pragma: no-cache'); //HTTP/1.0
  5. ?>

Use the above code to tell the browser not to cache the page.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: Delete temporary file on users machine?

 
0
  #3
Dec 4th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Delete temporary file on users machine?

 
0
  #4
Dec 4th, 2007
This might help.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: Delete temporary file on users machine?

 
0
  #5
Dec 4th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Delete temporary file on users machine?

 
0
  #6
Dec 4th, 2007
yep..
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: nathanpacker is an unknown quantity at this point 
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: Delete temporary file on users machine?

 
0
  #7
Dec 4th, 2007
Well, I tried putting this in the <head> tags of the page:

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

As well as this:

<META http-equiv="Pragma" content="no-cache">

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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Delete temporary file on users machine?

 
0
  #8
Dec 4th, 2007
hmm.. well, i am kinda lost too. But, If you can use javascript, try location.href="status.html". Some other alternatives (?). Try
<META HTTP-EQUIV="EXPIRES"
CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> or, you can redirect to another page, say, page1.html and then, redirect back to status.html.

If no-cache doesn't work, then i don't know what will ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC