TechniqueUse the clearstatcache() function before calling any of the previously listed status functions. <?php if (fileperms ($fn) < 644) { chmod ($fn, 0644); } clearstatcache(); if (fileperms ($fn) < 644) { die('chmod failed'); } ?> CommentsBecause the status functions are so taxing on the system when called, the results of these functions are cached for faster access. Therefore, you must clear the stat cache with the clearstatcache() function. Please note that results from the status functions are cached only for the lifetime of the program execution, meaning that if you call the function only once for a particular file, you do not need to clear the cache. In the following example, a clearstatcache() function call would be unnecessary. <?php if (file_exists($fn)) { print "$fn exists"; } if (is_readable ($fn)) { print "$fn is readable"; } unlink ($fn); if (file_exists ($new_file)) { print "$new_file exists"; } ?> |