Re: Directory size
| From: | Jeff Pauls | Date: | Tue, 11 Feb 2003 15:30:51 +0000 |
| Subject: | Re: Directory size | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135197@lists.php.net to get a copy of this message | ||
You can try something like this.
$dir = "dir";
function dirsize($checkdir) {
$dh = opendir($checkdir);
$size = 0;
while (($file = readdir($dh)) !== false)
if ($file != "." and $file != "..") {
$path = $checkdir."/".$file;
if (is_dir($path))
$size += dirsize($path);
elseif (is_file($path))
$size += filesize($path);
}
closedir($dh);
$formated_size = $size /1000;
return $formated_size;
}
$getFolderSize = dirsize("/files/personal");
Jeff
----- Original Message -----
From: "Marek Kilimajer" <kilimajer@webglobe.sk>
To: "Antti" <antti@victoria.fi>
Cc: <php-general@lists.php.net>
Sent: Monday, February 03, 2003 4:37 AM
Subject: Re: [PHP] Directory size
> there is no php function for this, you can use unix command du or do it
> in a loop
>
> Antti wrote:
>
> > How do I get the directory size? Suppose there is a function for this.
> >
> > antti
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>