note 24996 deleted from function.disk-total-space by cece

From: Date: Tue, 19 Aug 2003 12:45:02 +0000
Subject: note 24996 deleted from function.disk-total-space by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54666@lists.php.net to get a copy of this message
Note Submitter: ---- 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!"; ?>

« previous php.notes (#54666) next »