Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can you get, the total size of a certain directory?



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

Post New Answer

More PHP Interview Questions

How does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?

0 Answers  


Which function is used to strip whitespace?

0 Answers  


What php framework does wordpress use?

0 Answers  


What can I do by cakePHP?

4 Answers  


How to convert strings to numbers in php?

0 Answers  


What is the difference between array_merge() and array_merge_recursive() in php?

0 Answers  


What is __ construct in php?

0 Answers  


How To Get the Uploaded File Information in the Receiving Script?

0 Answers  


Tell me what are the correct and the most two common way to start and finish a php block of code?

0 Answers  


List out different arguments in PHP header function?

4 Answers  


What is difference between base_url and site_url?

0 Answers  


List out some tools through which we can draw E-R diagrams for mysql?

6 Answers  


Categories