anolan13 Posted July 1, 2007 Share Posted July 1, 2007 Hello all, All Ive been trying to do is make a short php script (embedded in the html, no separate file) that simply displays how much space, in megabytes, the contents of a certain folder is taking and use an echo command to display it. I've tried the filesize command and it always gives me 4,096 regardless of the contents. I assume this is because PHP is taking the size of the actual folder. I've tried disk_total_space but this displays a number that is completely off. I know this shouldn't be this hard. Any help is greatly appreciated. Thanks! Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 1, 2007 Share Posted July 1, 2007 try somthing like: exec("du -s *", $output); $var = arraytostring($output); $newoutput = explode("\t", $var); for($a=0;$a < count($newoutput);$a++ ) { echo $newoutput[$a]; } Quote Link to comment Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 try somthing like: exec("du -s *", $output); $var = arraytostring($output); $newoutput = explode("\t", $var); for($a=0;$a < count($newoutput);$a++ ) { echo $newoutput[$a]; } There is no such function as arraytostring(). If your using Linux, this function may help you. <?php function getdirsize($dir) { exec("du -chs $dir | awk '{print $1}'", $out); return $out[1]; } // example. echo getdirsize("/tmp"); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.