You are here: Re: How to get the given directory size? « PHP Programming Language « IT news, forums, messages
Re: How to get the given directory size?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация