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 can you upload a file using php?
my english is not too good then what we apply for a php programer post
Which function is used in php to count the total number of rows returned by any query?
How to create a web form?
What is difference between single quotes and double quotes in php?
Which database is best for php?
What is whitespace in html?
Will a comparison of an integer 12 and a string "13" work in php?
How to create an array from php string?
Can age be a variable?
What is namespaces in PHP?
What is use of in_array() function in php?