1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<?php $sizeG=0;$size=0; function recursive_calcul($path) { global $size; $O = dir($path); if(!is_object($O)) return false; while($file = $O -> read()) { if($file != '.' && $file != '..') { if(is_file($path.'/'.$file)) { $sizeF=filesize($path.'/'.$file); $size+=$sizeF; } else if(is_dir($path.'/'.$file)) recursive_calcul($path.'/'.$file); } } // !!!! il faut bien apeller 2 fois la méthode close() !!! $O -> close(); $O -> close(); return $size; } //$paths="I:\NAJIB I\EasyPHP\www"; //$sizeG=recursive_calcul($paths); //echo "<br>la taille du repertoire ".basename($paths)." est $sizeG Octets <b r>"; ?>
|