/ Published in: PHP

This code allows to calculate the full size of a directory using PHP.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Calculate the full size of a directory * @param string $DirectoryPath Directory path */ function CalcDirectorySize($DirectoryPath) { // I reccomend using a normalize_path function here // to make sure $DirectoryPath contains an ending slash // To display a good looking size you can use a readable_filesize // function. $Size = 0; if (!$Dir) return -1; // Skip file pointers if ($File[0] == ) continue; // Go recursive down, or add the file size $Size += CalcDirectorySize($DirectoryPath . $File . DIRECTORY_SEPARATOR); } else { } } return $Size; } ?>
URL: www.apphp.com/index.php?snippet=php-calculate-directory-size
Comments
