[PHP-DEV] Bug #1021: Filesize seems to cache file size result From: gmr <email protected>
Date: 01/02/99

From: gmr <email protected>
Operating system: Linux
PHP version: 3.0.6
PHP Bug Type: Other
Bug description: Filesize seems to cache file size result

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);
    }
  }

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>