Forum Moderators: coopster

Message Too Old, No Replies

filesize function not working

Outputs stat failed: WHY?

         

dbarasuk

9:58 pm on Aug 9, 2008 (gmt 0)

10+ Year Member



HI,
Can anyone know what's wrong with the next small piece of code?

<?php
$file = "C:/htdocs/Myname/HTML/accueil.php";
// calculate size in bytes
$bytes = filesize($file);
$kilobytes = round($bytes/1024, 0);
printf("File %s is %d bytes or %d kilobytes", basename($file), $bytes, $kilobytes);
?>

It's outputting:

Warning: filesize() [function.filesize]: stat failed for C:/htdocs/Myname/HTML/accueil.php in C:\htdocs\filesize.php on line 4

Line 4 refers to $bytes = filesize($file);

Thanks for your help

dreamcatcher

7:12 am on Aug 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the directory writeable? Check the notes on the PHP website to see if anything is mentioned there?

[uk2.php.net...]

dc

eeek

11:36 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The warning is saying that the stat call (it gets the file statistics) didn't work. Does the file exist? Can it be accessed?

Try opening the file. If it doesn't open, check the error code. That might tell you a lot.