note 44724 deleted from function.filesize by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 14 Aug 2004 17:12:02 +0000 |
| Subject: | note 44724 deleted from function.filesize by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74637@lists.php.net to get a copy of this message | ||
Note Submitter: simon [at] vhostdirect [dot] co [dot] uk
----
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