Félix Gagnon-Grenier Félix Gagnon-Grenier - 2 years ago 59
HTML Question

How to make an image update on screen if the filename does not change?

I have an image

<img src="whatever.jpg">

An AJAX request uploads a different image to the server, replacing the file. When reloading I can see the new image.

How to make the image show the new file without reloading the page?

Answer Source

The solution posted here inspired a simple solution; add a timestamp to the query string of the src attribute when uploading the file with success.

<img src="whatever.jpg?2874652">

Which will cause browsers to reload the file from the server.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download