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 do I escape data before storing it in the database?
What is the apache?
Is laravel frontend or backend?
Is it worth learning php in 2019?
Do I need to install php after xampp?
How to retrieve values out of an array?
How to get the number of characters in a string?
Is php procedural or oop?
I need to know about the courses which are useful in corporate companies.. especially php/mySQL, Java/j2ee, .NET.. also tell if any other courses are valuable
What is the difference between a session and cookies?
=== represents what?
2 Answers Ephron Systems, NetTrackers,
What is final in php?