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
How to execute an sql query? How to fetch its result?
Can you specify the "new line" character in single-quoted strings?
Does https prevent csrf?
What are different types of errors available in Php?
How to remove duplicate values from a PHP Array?
How do you measure variables?
How to turn on the session support?
Explain mixed and callback functions?
What is rest api in php?
What is isset in php form?
Write a program to display reverse of any number?
How do you trim spaces in excel?
Tell me how can we pass the variable through the navigation between the pages?
What is the function of trim?
Which php framework is in demand?