note 19526 deleted from function.disk-total-space by nlopess
| From: | nlopess@php.net | Date: | Mon, 03 May 2004 13:37:42 +0000 |
| Subject: | note 19526 deleted from function.disk-total-space by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69137@lists.php.net to get a copy of this message | ||
Note Submitter: madchaz@madchaz.com
----
If you want to use this to give the user the size of his account (or the admin the size of the
user's folder) in a more human readable format, you can use this
function dirsize($dir) {
$dh = opendir($dir);
$size = 0;
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..") {
$path = $dir."/".$file;
if (is_dir($path))
$size += dirsize($path);
elseif (is_file($path))
$size += filesize($path);
}
closedir($dh);
$mgs_size = $size/1048576;
return $mgs_size;
}
it will return the value in megabytes so it's more easy to read. This is a negligable addition
to the very usefull function posted by flagzen