How can you get, the total size of a certain directory?
Answer Posted / suren
You can use the folowing function as shown in alt.php by
ryanflynnn at my-deja.com:
<?php
$totalsize=0;
function show_dir($dir, $pos=2){
global $totalsize;
if($pos == 2)
echo "<hr><pre>";
$handle = @opendir($dir);
while ($file = @readdir ($handle)){
if (eregi("^\.{1,2}$",$file))
continue;
if(is_dir($dir.$file)){
echo "|- ".$pos."s <b>$file</b>\n";
show_dir("$dir.$file/", $pos+3);
}else{
$size=filesize($dir.$file);
echo "|- ".$pos."s $file ";
echo("$size <br>");
$totalsize=$totalsize+$size;
}
}
@closedir($handle);
if($pos == 2) echo "</pre><hr>";
return($totalsize);
}
$totalsize = show_dir("c:/winnt/system32/");
echo($totalsize);
?>
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Does exist in php?
Suppose your zend engine supports the mode Then how can you configure your php zend engine to support Mode ?
Is php used anymore?
What is the use of super-global arrays in php?
Does php support multiple inheritances?
What is array filter in php?
What is the use of session and cookies in php?
Can I use php in visual studio?
Can php run on windows server?
What are form input html tags?
Do you know what is the differences between $a != $B and $a !== $B?
Tell me how can we get the error when there is a problem to upload a file?
Tell me what does the initials of php stand for?
Whether it is possible to share a single instance of a memcache between multiple php projects?
Is php dying 2018?