How can you get, the total size of a certain directory?
Answer / 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 |
Who is the father of php and what is the current version of php and mysql?
Where php basically used?
What are magic methods in php
How to create reusable code in php?
what is hidden variable? what is its difference with the normal variable...
How to pass variables by references?
What is $this in php?
What are the three parts of an http request?
What does $_ post mean in php?
How does php strcmp work?
How many data types are there in php?
What is cakephp framework?