Problems with images not updating on upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Problems with images not updating on upload

Post by mjseaden »

Dear All

I've just more or less finished making a database 'add' feature on my site which allows the user to add text information about their item, and further upload 4 photographs of that item.

I follow the usual procedure for uploading the pictures, first using the FILE - submit routine for uploading the photographs to a temporary location, then use move_upload_file to move the file to a more permanent position on the server. The photographs are then displayed on an item information preview page.

However, I have noticed that whilst the first time I got the code to work, the photographs showed up as expected, I now notice that if I add another item and different photographs, the preview page shows the old photographs. It is not until I deliberately hit the 'refresh' button that the photographs update with the new ones, despite the fact that they are on the server and <IMG SRC="... is pointing to them correctly (otherwise they wouldn't show up when I hit 'refresh').

Is there anything I can do about this, otherwise my preview feature is redundant?

Many thanks

Mark
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Just to clarify, by 'old photographs' I mean the photographs that of a previous item I tried to add.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

It's probably just the browser caching them as i'm guessing all the preview images have the same name?
Either way, you could try giving each preview image a unique name (maybe use time() or uniqid()) or try using a no-cache header.
http://php.net/header has some cache header examples
Post Reply