Page needs to be refreshed twice for correct photo to appear

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geniajanssen
    New Member
    • Jan 2007
    • 12

    Page needs to be refreshed twice for correct photo to appear

    I have a folder called "events" for guest speakers. There is one file there called "guest_pic1.jpg ".

    Here is what happens:

    1. I select a picture from my local disk
    2. I hit "submit" and it uploads properly.
    3. Picture displays properly when page is reloaded.
    4. Now, I select a different picture from my local disk.
    5. I hit "submit" and it uploads properly, overwriting the original picture.
    6. I now reload the page but the original picture is there, not the new one.
    7. However, if I refresh the buffer again, the new picture displays correctly.

    Do you know why this is happening?
  • brettl
    New Member
    • Sep 2007
    • 41

    #2
    Sounds like the image is being cached by the browser.


    Originally posted by geniajanssen
    I have a folder called "events" for guest speakers. There is one file there called "guest_pic1.jpg ".

    Here is what happens:

    1. I select a picture from my local disk
    2. I hit "submit" and it uploads properly.
    3. Picture displays properly when page is reloaded.
    4. Now, I select a different picture from my local disk.
    5. I hit "submit" and it uploads properly, overwriting the original picture.
    6. I now reload the page but the original picture is there, not the new one.
    7. However, if I refresh the buffer again, the new picture displays correctly.

    Do you know why this is happening?

    Comment

    • recordlovelife
      New Member
      • Sep 2007
      • 31

      #3
      Try this...

      Add this line to your form.

      [HTML]<input type="hidden" name="i" value="<?=rand( )?>">[/HTML]

      now pass "i" into the url. The rand() will generate a random number every time the page is loaded. When it gets passed in the url, the browser will not cache the photo because it will think its a new page because the url keeps changing (thanks to the random int you keep passing).

      Hope this helps

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by recordlovelife
        Try this...

        Add this line to your form.

        [HTML]<input type="hidden" name="i" value="<?=rand( )?>">[/HTML]

        now pass "i" into the url. The rand() will generate a random number every time the page is loaded. When it gets passed in the url, the browser will not cache the photo because it will think its a new page because the url keeps changing (thanks to the random int you keep passing).

        Hope this helps
        Incase that causes problems:

        [HTML]<input type="hidden" name="i" value="<?php echo rand();?>">[/HTML]

        :)

        Comment

        Working...