note 22901 added to function.disk-total-space

From: Date: Wed, 03 Jul 2002 16:26:42 +0000
Subject: note 22901 added to function.disk-total-space
Groups: php.notes 
Request: Send a blank email to php-notes+get-32555@lists.php.net to get a copy of this message
This is an edited version of Madchaz's piece of code (see above). I found the code really useful! <?PHP function dirsize($dir) { $dh = opendir($dir); $size = 0; while (($file = readdir($dh)) !== false) if ($file != "." && $file != "..") { $path = $dir."/".$file; if (is_dir($path)) $size += dirsize($path); elseif (is_file($path)) $size += filesize($path); } closedir($dh); return $size; } $totalsize = round((dirsize("/this/is/your/directory") / 1048576), 1); echo number_format($totalsize, 1, ',', ' '); // Prints the size of your directory and // all its subdirectories. Example: "80,9". ?> Regards, Tuomo Björksten / www.tuomomedia.fi -- http://www.php.net/manual/en/function.disk-total-space.php http://master.php.net/manage/user-notes.php?action=edit+22901 http://master.php.net/manage/user-notes.php?action=delete+22901 http://master.php.net/manage/user-notes.php?action=reject+22901

« previous php.notes (#32555) next »