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 |
Sir, I want sbi clearical post model question paper please sent my mail id srinivas_33000@ahoo.co.in
0 Answers State Bank Of India SBI,
What are majic methords in php?
What are the rules to declare a php variables?
What is a string in r?
What is meant by content management system?
3 Answers Global Logic, IBEE, TCS, Toyota,
What is the difference between fopen() and fclose()?
Tell me how can we change the maximum size of the files to be uploaded?
Write the code for upload a video file in PHP.How will You Play this in Your Page.?
2 Answers ASD Lab, Convex Digital,
Tell me what are the different types of errors in php?
Is age an interval or ratio?
What is polymorphism in oop php?
In php how can you jump in to and out of "php mode"?