Re: Getting Dir Size?
| From: | Brian Clark | Date: | Mon, 08 Jan 2001 21:26:16 +0000 |
| Subject: | Re: Getting Dir Size? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33321@lists.php.net to get a copy of this message | ||
Hello Chris,
(CAPA == "Chris Anderson {Programmer Always}") chrisderson@ameritech.net writes:
CAPA> Is their a way to get the size of all the files in a dir with
CAPA> php?
This doesn't traverse subdirectories, but it's a start.
Hack away:
<?php
/* Untested code */
$directory = '.'; /* current directory */
$size = 0;
$handle = @opendir($directory);
while($file = @readdir($handle))
{
if(! ereg("\.{1,2}$", $file))
{
if(! is_dir($file))
{
$array = stat($file);
$size += $array[7]; /* accumulative */
}
}
}
@closedir($handle);
?>
-Brian