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 |
What is MIME?
How to create reusable code in php?
What is meant by nl2br()?
4 Answers Rushmore Consultancy,
What is the difference between super () and this ()?
What is sql injection in php?
What is http get and post?
What is the use of mysql_real_escape_string in php?
Tell me what is the difference between the functions strstr() and stristr()?
How can we upload a php + mysql Site
How can we pass the variable through the navigation between the pages?
What is the importance of parser in php?
What is null value in php?