0

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?

Félix Gagnon-Grenier
  • 7,344
  • 10
  • 45
  • 58

1 Answers1

0

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.

Community
  • 1
  • 1
Félix Gagnon-Grenier
  • 7,344
  • 10
  • 45
  • 58