filesize() giving errors [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

filesize() giving errors [SOLVED]

Post 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
Last edited by mikeeeeeeey on Tue Apr 10, 2007 10:55 am, edited 1 time in total.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

You need to replace this:

Code: Select all

filesize($file)
With this:

Code: Select all

filesize('assets/' . $file)
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Post by mikeeeeeeey »

Oren, you legend. Thanks alot.
I am so st00pid, lol :D
Post Reply