I have an upload form where the uploaded picture is displayed. This works perfectly in Firefox. Problem is that in Internet Explorer, the image only displays when the page is refreshed. I do not want my users to have to do this, any tips? I tried just about every solution that was given around the web, but nothing works. I tried:

header("Pragma: no-cache");
    header("Cache: no-cache");
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

and this:

header('Location: http://www.example.com');

I tried adding a refresh in my actual form tags (onclick="..."), but that was processed too soon after, and it didn't hold my image. (this problem was also only in IE)

This seems like a very common problem, something having to do with keeping the cache. So my question is- why can't I find a solution that works?

Thanks in advance.

Recommended Answers

All 2 Replies

I have an upload form where the uploaded picture is displayed.

Once you upload the picture, what code are you exactly executing? Are you:
a. emitting an <IMG> tag with the path to the newly uploaded image
b. redirecting to the newly uploaded image
c. Other???

If you are doing a or b, instead of pointing to image.gif, try pointing to image.gif?cb=XXX where X is some random number - You can use the time() function to guarantee that it will be different every time:

header( 'Location: http://www.example.com/image.gif?cb=' . time() );

Thanks so much! That did it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.