folder size calculation

Hello

No problem on my laptop on the local server in XP,
But it doesn’t calculate folder size in remote linux server
What is the problem? What should I do?

[php]
$dirr = realpath(".")."./".$dir."/".$folder."/*";
$size = 0;
foreach(glob($dirr) as $file){
if(is_file($file)){
$size = $size += filesize($file);
}
}
[/php]

Thanks

Try to use this function
[php]function foldersize($dir) {
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
foreach ($dir_array as $key => $filename) {
if ($filename != “…” && $filename != “.”) {
if (is_dir($dir . “/” . $filename)) {
$new_foldersize = foldersize($dir . “/” . $filename);
$count_size = $count_size + $new_foldersize;
} else if (is_file($dir . “/” . $filename)) {
$count_size = $count_size + filesize($dir . “/” . $filename);
$count++;
}
}
}
return $count_size;
}[/php]

Thank you very much

Sponsor our Newsletter | Privacy Policy | Terms of Service