Forum Moderators: coopster
I've written a script to upload images to my server. Everything works perfect so I don't think theres a need to add code here. However one issue I'm having is that after the script executes, the page has to be manually refreshed in order for the new picture to show up; otherwise, the old picture is still there. After my script I have added a header("Location: picture.php") line to refresh from the script, but this still doesn't work. Any ideas?
Thanks so much!
PS. if it is relevant, i'm using the unlink function and the copy function to take off the old picture and add the new one.
Try to send the headers:
PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with:
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
Michal
If you are using Apache you can use mod_expires [httpd.apache.org] together with an ExpiresByType [httpd.apache.org] declaration in your virtual host conf.
<location /uncacheable_images/>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "modification"
</IfModule>
</location>