note 46088 added to function.ftp-size
| From: | php-general at lists dot php dot net | Date: | Wed, 29 Sep 2004 01:10:21 +0000 |
| Subject: | note 46088 added to function.ftp-size | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77548@lists.php.net to get a copy of this message | ||
To get a dirsize recursive you can use this simple function:
<?php # copyright by fackelkind | codeMaster
function getRecDirSize ($connection, $dir){
$temp = ftp_rawlist ($connection, "-alR $dir");
foreach ($temp as $file){
if (ereg ("([-d][rwxst-]+).* ([0-9]) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*)
([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)", $file, $regs)){
$isdir = (substr ($regs[1],0,1) == "d");
if (!$isdir)
$size += $regs[5];
}
}
return $size;
}
$dirSize = getRecDirSize ($conID, "/");
?>
----
Manual Page -- http://www.php.net/manual/en/function.ftp-size.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46088
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46088&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46088&report=yes
Search -- http://master.php.net/manage/user-notes.php