Forum Moderators: coopster

Message Too Old, No Replies

Warning when using filesize()

         

Numberman

7:17 am on Apr 30, 2004 (gmt 0)

10+ Year Member



When I use the fuction filesize() in a document, I get the following warning:

Warning: stat failed for (errno=2 - No such file or directory) in /home/httpd/vhosts/ut2k4mods.com/httpdocs/benstock/admin/admin.php on line 43

The actual function works (it displays the corrent size). How can I rectify the error?

hakre

2:20 pm on Apr 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi numbermann,

if you're shure it works even you get the stats error, use this it with an '@' in front:

[b]@[/b]filesize();
.

this will prevent displaying error and warning messages of only this statement, so you won't need to modify error reporting parameters for it.

anyways, the error message states that the file has not be found, so the filesize couldn't be return correctly in theory. check clearstatcache [php.net], this might help if the file exists for real.

--hakre

Numberman

5:16 pm on Apr 30, 2004 (gmt 0)

10+ Year Member



I was getting the error because I was using filesize() in a function that didn't define a value for it (I was using a function take to get it).

Thanks for your help, now I don't get the error.

yt404

1:09 pm on May 2, 2004 (gmt 0)

10+ Year Member



i had the same error, the file didn't exist, check if the file is there

WhosAWhata

8:07 pm on May 2, 2004 (gmt 0)

10+ Year Member



if the file may or may not be there the way to go is to either use @ or an if statement

ex1.
$file="file.txt";
@unlink($file);

ex2.
$file="file.txt";
if(file_exists($file)) {
unlink($file);
}