SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When uploading pics to a website I have some caching problems concerning displaying pictures correctly.

    I use this to display the uploaded picture:

    $path="/usr/......";

    if (file_exists("$path"))
    { $picture = "$username.jpg";

    echo "<tr><img src='pic.php?pic="$picture"' border=1 alt='$username' ><a href='$PHP_SELF?id=$id&delpic=$picture>Delete picture</a></td></tr>";

    } // end if file exists

    else {
    echo "<tr><td>No image</td></tr>";
    }

    -----------
    The pic.php looks like this:

    <?php
    header("Content-type: image/jpeg");
    header("Pragma: no-cache");
    header("Cache-Control: no-cache");
    header("Cache-Control: no-store");

    readfile("../images/$pic")
    ?>
    ------------

    But this doesn't seem to be working well either,

    What more measures do I have to take to to display the page correctly?

    For example when a picture is deleted, php somehow still thinks it exists and tries to display the page which will result in an image not found.
    So i still need to refresh the page again to have it displayed correctly.

    Anyone know how to solve this?
    Last edited by jamesbond; Mar 2, 2001 at 09:19.

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Call clearstatcache() before you check for file_exist
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Addict jamesbond's Avatar
    Join Date
    Feb 2001
    Location
    The Netherlands
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That doesn't seem to help, I still need an extra refresh to get the new picture to show up.

    And when I delete the picture, php still seems to think it still exists so I get a 'no image found'. (after a refresh the page is displayed correctly)

    How can I work around this problem?

    Could it be that the filecheck is executed before a new picture has been fully uploaded? And also that the filecheck is executed before a picture is fully deleted?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •