...

View Full Version : directory size



zodehala
12-19-2007, 10:32 PM
how can we find dir size?

Fumigator
12-19-2007, 10:42 PM
Probably build a file list in the dir via glob() and use filesize to tally the size of all the files in the dir. You'll want to make it recursive so it tallies files inside dirs inside the dirs.

oesxyl
12-19-2007, 10:46 PM
how can we find dir size?

try:

http://www.php.net/manual/en/function.stat.php

in comment secion post of marting.dc AT gmail.com and addition of JulieC



<?
function dir_size($dir)
{
$handle = opendir($dir);
$mas = 0;
while ($file = readdir($handle)) {
if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) {
$mas += filesize($dir.'/'.$file);
} else if (is_dir($dir.'/'.$file) && $file != '..' && $file != '.') {
$mas += dir_size($dir.'/'.$file);
}
}
return $mas;
}
echo dir_size('DIRECTORIO').' Bytes';
?>


I don't test this.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum