I have this code that checks for a file if it exists and do something if it doesnt exist. Problem exist when im updating my data on the directory, even if i did upload it. it still shows the non-existent data.
I have read that i should add the clearstatcache();, how am i going to use it? after the file_exists? or before?
here's my code
## $itemCode_SHOW = $row[2]; $filename =("/www/images/stockprod/$itemCode_SHOW.jpg");
if (file_exists($filename)) { $itemCode_SHOW = $row[2]; } else { $itemCode_SHOW = "noimage"; }
clearstatcache(); ##
clearstatcache() is very descriptive for php, actually :). Most filesystem functions make use of statistics about a file. Gathering this information is expensive, so it is cached. If something changes, you have to clear the cache to see the change, so:
clearstatcache(); if (file_exists($filename)) {
is what you need
if (file_exists($filename)) { ... } clearstatcache();
will have no impact on the problem, because you are clearing the cache *after* the function that relies on the cache has been called.
Greg
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php