ça te convient ?
<?php
function foldersize($path) {
$total_size = 0;
$files = scandir($path);
foreach($files as $t) {
if (is_dir($t)) {
if ($t<>"." && $t<>"..") {
$size = foldersize($path . "/" . $t);
$total_size += $size;
}
}
else {
$size = filesize($path . "/" . $t);
$total_size += $size;
}
}
return $total_size;
}
function format_size($size , $round) {
//Size must be bytes!
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024;
return round($size,$round).$sizes[$i];
}
$total_size = foldersize("Mondossier");
echo format_size ($total_size, 2 )
?>