Page 1 of 1

get folder attributes

Posted: Wed Aug 27, 2003 11:19 am
by yaron
Hello all,
How can I get a folder's attributes.
I want to get the folder size,how many files are in it and most important the folder's date

Thank you

Posted: Wed Aug 27, 2003 11:22 am
by JayBird
You can try something like this for the directory size

Code: Select all

$dir = "dir"; 


function dirsize($checkdir) { 
    $dh = opendir($checkdir); 
    $size = 0; 
    while (($file = readdir($dh)) !== false) 
        if ($file != "." and $file != "..") { 
            $path = $checkdir."/".$file; 
            if (is_dir($path)) 
                $size += dirsize($path); 
            elseif (is_file($path)) 
                $size += filesize($path); 
        } 
    closedir($dh); 
 $formated_size = $size /1000; 
    return $formated_size; 
} 


$getFolderSize = dirsize("/files/personal");