Todays problem involved refreshing an image after uploading using a FileUpload control. The issue was that although the file was changing on the server, the file name was staying the same. This results in the browser displaying the old file as it is being retrieved by the browsers cache. To avoid this problem you need to add a unique querystring parameter to the image url. You can achieve this with the following code:
string lsTimeStamp = DateTime.Now.ToString("yyyyMMddhhmmss");
Image1.ImageUrl = lsImageName + "?ts=" + lsTimeStamp;
Hi, just wondering…would this work for other server-side languages too? I’m using PHP right now…hopefully .NET at some point but I was having a similar problem you see…Googled it and found this page
Nice site by the way!! Sorry for the newbie question.
Cheers
Cheers, yes this technique would work for any language, all you are doing is forcing the local users machine to download the image again instead of retrieving it from its cache.
Useful trick. Thanks
thanks buddy……..
I tried the way you suggested but did not work for me.
I have to press “F5″ to see the newly uploaded image,,,
please suggest …