Page 1 of 1

filesize() giving errors [SOLVED]

Posted: Tue Apr 10, 2007 10:43 am
by mikeeeeeeey
Hi guys,
hope you all had a great easter. I've got a function here which I've been working on to give me information about a folders contents, but I'm stuck at the filesizes. Here's the code:

Code: Select all

function parseFolder($folder){
  $handle = opendir("assets/" . $folder);
  while (($file = readdir($handle)) !== false){
    if ($file != "." && $file != ".."){
      echo filesize($file) . "<br/>";
    }
  }
  closedir($handle);
}

parseFolder("templates");
And here's the errors (one of these for each file found):

Code: Select all

Warning: filesize() [function.filesize]: stat failed for Filename.doc...
I've googled the error and found nothing. Surely there's gotta be something holding it all up?

Thanks in advance you lovely PHPeople

Posted: Tue Apr 10, 2007 10:52 am
by Oren
You need to replace this:

Code: Select all

filesize($file)
With this:

Code: Select all

filesize('assets/' . $file)

Posted: Tue Apr 10, 2007 10:55 am
by mikeeeeeeey
Oren, you legend. Thanks alot.
I am so st00pid, lol :D