note 44724 added to function.filesize
| From: | simon | Date: | Sat, 14 Aug 2004 09:50:19 +0000 |
| Subject: | note 44724 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74621@lists.php.net to get a copy of this message | ||
Hi all PHP users this is my second post to the php manual. Hopefully this will help some people.
If you want to get the total amount of space a directory takes up including all sub directories in
bytes then try this.
<?php
$fulldir = "/full/path/to/sub/directory/";
$used_diskspace = ((int)exec("du ".$fulldir." | awk '{print \$1}'") *
1024);
?>
Now $used_diskspace contains the total amount of bytes used by $fulldir directory.
Normally this is quicker and out performs a lot these php functions. Please note that I am unsure if
this will work in safemode, please can someone test and post about it for everyone elses benefit.
Glad I can help.
Simon Lightfoot
vHost Direct Limited
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44724
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44724&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44724&report=yes
Search -- http://master.php.net/manage/user-notes.php