Hello all I need a simple PHP code snippet that will allow me to see the total disk space used by files in my "uploads" directory. The script will be placed in the /admin directory and /uploads is in the root folder. Thanks
You should've posted this in the PHP forums. Anyway, you'll need recursion for this type of function. I wrote this one and tested it. Works for me. <?php function getdirsize($dir) { $size = 0; $files = scandir($dir); foreach ($files as $file) { if (strlen(str_replace('.', '', $file))>0) { if (is_dir($dir.'/'.$file)) { $size += getdirsize($dir.'/'.$file); } else { $size += filesize($dir.'/'.$file); } } } return $size; } echo getdirsize('uploads'); ?> PHP: