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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gmr at nextpath dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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 May 16 11:01:31 2024 UTC