Page 1 of 1

how to get directory/folder size and delete files inside

Posted: Thu Jun 17, 2010 2:44 pm
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

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

Posted: Thu Jun 17, 2010 2:55 pm
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.