how to get directory/folder size and delete files inside

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dss.Lexius
Forum Newbie
Posts: 11
Joined: Fri Jun 11, 2010 12:18 pm

how to get directory/folder size and delete files inside

Post by Dss.Lexius »

hi,
i want to get size of a Directory and delete a file called old.php when the directory's total size is larger than 500mb.
how to do it?
i am new to PHP trying to make my work easy using PHP
help me plz...
Thanx
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: how to get directory/folder size and delete files inside

Post by AbraCadaver »

As far as I know you need to loop through the directory using glob() maybe and add the filesize() of each file. If the directory contains subdirectories then you need to recursively list files within those etc... If on linux you could just exec() the du command.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply