|  | Posted by NC on 04/24/06 20:03 
mail2ganeshguru@gmail.com wrote:>
 > i want to calculate the size of the folders. Please give me some
 > suggestion in this.
 
 A directory is 4096 bytes long on most Unix versions.  But, then,
 your real question is not about the directory, it's about files in that
 
 directory, right?  If so, here's a possibility:
 
 $dir = '/path/to/files';
 $size = 0;
 if ($handle = opendir($dir)) {
 while (false !== ($file = readdir($handle))) {
 $size = $size + filesize("$dir/$file");
 }
 closedir($handle);
 }
 echo "Total size of files in $dir: $size bytes";
 
 For more information, see:
 
 http://www.php.net/readdir
 http://www.php.net/filesize
 
 Note that the code above totals up only files in the
 specified directory; files in subdirectories are ignored.
 
 Cheers,
 NC
  Navigation: [Reply to this message] |