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 |
How does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?
Which function is used to strip whitespace?
What php framework does wordpress use?
What can I do by cakePHP?
How to convert strings to numbers in php?
What is the difference between array_merge() and array_merge_recursive() in php?
What is __ construct in php?
How To Get the Uploaded File Information in the Receiving Script?
Tell me what are the correct and the most two common way to start and finish a php block of code?
List out different arguments in PHP header function?
What is difference between base_url and site_url?
List out some tools through which we can draw E-R diagrams for mysql?