php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1021 Filesize seems to cache file size result
Submitted: 1999-01-02 14:57 UTC Modified: 1999-02-21 15:51 UTC
From: gmr at nextpath dot com Assigned:
Status: Closed Package: Other
PHP Version: 3.0.6 OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 29 = ?
Subscribe to this entry?

 
 [1999-01-02 14:57 UTC] gmr at nextpath dot com
It seems, and maybe this is more relevant in notes, and is not a bug, that the filesize command caches it's last result for a filename, and when called again with the same filename, doesn't go out and requery the file size.  I have a small script which downloads a remote picture, runs getImageSize on it, then filesize.  When I download the file, I use the name tmp.jpg, and I do so sequentially.   thumb1 and thumb2 are different files with different sizes.  Filesize returns the same filesize for both because they are written out using the same filename.  

 // Thumb1
  if ( $thumb1 ) {
    $fileIn = fopen($thumb1,  "r");
    if ( $fileIn ) {
      $data = fread($fileIn, 500000);
      fclose($fileIn);
      $fileOutName =  "/tmp/tmp.jpg";
      $fileOut = fopen($fileOutName,  "w");
      fwrite($fileOut, $data);
      fclose($fileOut);
      $size = GetImageSize($fileOutName);
      $thumb1w= $size[0];
      $thumb1h= $size[1];
      $thumb1size = $size[3];
      $thumb1s = FileSize($fileOutName);
    }
  }
// Thumb 2
  if ( $thumb2 ) {
    $fileIn = fopen($thumb2,  "r");
    if ( $fileIn ) {
      $data = fread($fileIn, 500000);
      fclose($fileIn);
      $fileOutName =  "/tmp/tmp.jpg";
      $fileOut = fopen($fileOutName,  "w");
      fwrite($fileOut, $data);
      fclose($fileOut);
      $size = GetImageSize($fileOutName);
      $thumb2w= $size[0];
      $thumb2h= $size[1];
      $thumb2size = $size[3];
      $thumb2s = FileSize($fileOutName);
    }
  }

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-02-21 15:51 UTC] jim
You need to use the clearstatcache() function.
A note should be added to all of the relevant
functions pointing this out.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC