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

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?

0 Answers  


What are the rules to declare a php variables?

0 Answers  


What is a string in r?

0 Answers  


What is meant by content management system?

3 Answers   Global Logic, IBEE, TCS, Toyota,


What is the difference between fopen() and fclose()?

0 Answers  


Tell me how can we change the maximum size of the files to be uploaded?

0 Answers  


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?

0 Answers  


Is age an interval or ratio?

0 Answers  


What is polymorphism in oop php?

0 Answers  


In php how can you jump in to and out of "php mode"?

0 Answers  


Categories