Jump to content

Directory Size?

Recommended Posts

I found this www.alt-php-faq.org/local/25/

but it's lacking an interface so I changed it to include a form. If you need it for a purpose other than what I did with it then you can just use the original.

><form action="" method="post" name="form1">
 <p>Enter Directory Name - Leave empty for a listing of directories </p>
   <input name="directory" type="text" id="directory">
   <input type="submit" name="Submit" value="Submit">


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)) 
       echo "|- ".$pos."s <b>$file</b>\n"; 
       show_dir("$dir.$file/", $pos+3); 
       echo "|- ".$pos."s $file "; 
       echo("$size <br>"); 

   if($pos == 2) echo "</pre><hr>"; 


$totalsize = show_dir("/home/cpanelusername/public_html/$directory/"); 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...