I was wondering whether i could read the size of a directory using PHP. So i thought of making something which could help me read the size of the directory ,no. of directories and the no. of files in the given diretory.
The function "getDirectorySize" will ignore link/shorcuts to files/directory.
The function "sizeFormat" will suffix the size with bytes,KB,MB or GB accordingly.
Here is the code:

------------------------------------------------------------
This Article is written by S Pradeep for Programming Forum
------------------------------------------------------------

This article is freely available for reprint provided that the resource box at the end of the article is left intact and the article is published complete and unaltered. If you are using this article on a website or e-book, please make sure that the link in the resource box is live and clickable.

McFarnell

5Oct2007 05:48

Re: Calculate directory size using PHP

May I use this code on a web site? Is there some kind of copyright or credit notice I should include? Thanks.

shabbir

5Oct2007 08:58

Re: Calculate directory size using PHP

Quote:

Originally Posted by McFarnell

May I use this code on a web site? Is there some kind of copyright or credit notice I should include? Thanks.

Refer to the last line in the article which says what you should be doing. It should link to the forum and the link should be live and click-able.

McFarnell

5Oct2007 09:23

Re: Calculate directory size using PHP

Thanks. I wasn't sure because that line is referring to use the article, complete and unaltered. I'm not really using the article, just the code. I wasn't sure what the "resource box" was either. So if I just include a live link back to this thread, would that be acceptable?

shabbir

5Oct2007 11:03

Re: Calculate directory size using PHP

Quote:

Originally Posted by McFarnell

Thanks. I wasn't sure because that line is referring to use the article, complete and unaltered. I'm not really using the article, just the code. I wasn't sure what the "resource box" was either. So if I just include a live link back to this thread, would that be acceptable?