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
Write a program in php to reverse a number?
What is if isset ($_ post submit )) in php?
am from coimbatore.am learning php&mysql. what will be the approx salary for me if i get a job in coimbatore.
sort term descripttion form, report and uery
What is full form of php? Who is the father or inventor of php?
Are react hooks stable?
why did u want to leave your past organisation?
what does this symbol mean in php?
Which method do you follow to get a record from a million records? (Searching not from database, from an array in php)?
hello all, I need some sample placement papers in lion bridge.. can anyone help me?
Which php framework is in demand?
How to generate a form?
What is the function used to change the root directory in PHP?
What are the delimiters in php?
Does php support function overloading?