PHP Code:
<?php
function GetFolderSize($d ="." ) {
$h = @opendir($d);
if($h==0)return 0;
while ($f=readdir($h)){
if ( $f!= "..") {
$sf+=filesize($nd=$d."/".$f);
if($f!="."&&is_dir($nd)){
$sf+=GetFolderSize ($nd);
}
}
}
closedir($h);
return $sf ;
}
?>
GetFolderSize - This function shows the size of the file. In example above, the script reads the directory and apply the function for an each file. Use these lines to see the result in the browser:
PHP Code:
<?php
echo " The Folder Size is : " . GetFolderSize( $path ) . " Bytes";
?>