note 24996 added to function.disk-total-space
| From: | php-general at lists dot php dot net | Date: | Sat, 07 Sep 2002 08:35:10 +0000 |
| Subject: | note 24996 added to function.disk-total-space | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36290@lists.php.net to get a copy of this message | ||
Just added some code already posted to spit out how many gigs of diskspace is used (to the
hundredths of a gig)
<?php
function dirsize($dir) {
// calculate the size of files in $dir, (it descends recursively into other dirs)
$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);
return $size;
}
$Space = dirsize("/home2/mp3/public_html/mp3");
$gigs_size = $Space/1073741824;
$roundgig = round($gigs_size,2);
echo "Current Size of Archive: $roundgig Gigabytes of music!";
?>
--
http://www.php.net/manual/en/function.disk-total-space.php
http://master.php.net/manage/user-notes.php?action=edit+24996
http://master.php.net/manage/user-notes.php?action=delete+24996
http://master.php.net/manage/user-notes.php?action=reject+24996