I am trying to upload a new picture into my webpage, but in t开发者_Go百科he browser it is showing the old picture. When I check in the folder the new image is being saved, but it is not showing in the page. I have tried refreshing, but it does not help. It is still the same after shutting down the browser. I have tested in different browser and it is still old image. I need help as to what can I do now. I'm uploading picture using PHP coding with Ajax.
I'm not sure I fully understand what you are trying to accomplish, but obviously there is some caching of sorts going on. If you've uploaded an image, with the same file name, and it refuses to refresh, or you simply don't want to depend on a refresh of the users cache, a simple solution would be to append a random number to the end of your image src after a question-mark. i.e.
<img src="/images/face.png?1234324">
...which will essentially make the browser believe the image is a new image (which it is), and thwart it's attempt to use the browsers cache.
Try pressing Ctrl-F5 in the browser. This should force a refresh of the cache.
If you are using a script to generate your pages, you could pass the no-cache http flag in the output headers for the image. The header would be:
Cache-control: no-cache
Edit: I see you are using php, is there any chance you could 'echo' the image in a separate php page? Then you could use the line
header("Cache-control: no-cache");
Are you updating the src attribute of the image tag with the new filename? o.O
Try clearing your cache THEN refresh the browser. There is the possibility that you are still seeing the cached image, despite the contents changing on the server.
Try renaming the picture with a different name.
精彩评论