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

From: Date: Tue, 19 Aug 2003 12:44:54 +0000
Subject: note 22901 deleted from function.disk-total-space by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54665@lists.php.net to get a copy of this message
Note Submitter: tuomo@*NO-SPAM*tuomomedia.fi ---- 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

« previous php.notes (#54665) next »