[SOLVED] disk_total_space

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

disk_total_space

Post by hward »

I am tryign to figure out how to show the total space of a directory

the directory is on a linux system /dir/dir/

I found this code on php.net

Code: Select all

<?php
// $df contains the total number of bytes available on "/"
$df = disk_total_space("/");

// On Windows:
disk_total_space("C:");
disk_total_space("D:");
?>
Does this only work on windows file systems?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

give this a try
>>>>it's out of the PHP manual....

Code: Select all

function Du($dir)
{
       $du = popen("/usr/bin/du -sk $dir", "r");
       $res = fgets($du, 256);
       pclose($du);
       $res = explode(" ", $res);
       return $res[0];
}
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

Post by hward »

thanks i put a couple together i found in the manual and got it working
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

great
Post Reply