Categories
PHP / MySQL

Delete Files Older than n Number Of days Using PHP?

Some times in application development, we required to delete files older than specified number of days. Actually below method removes older files from disk and free the hard disk memory.

Below example demonstrate how to delete files, older than specified number of days. This code delete files from specified directory only, not from child folders. deleteOldFiles() method takes three parameters first one is folder/directory path, second one is number of days and third parameter is return count.

Simple Method to Delete Files Older than n Number Of days

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

Leave a Reply

Your email address will not be published. Required fields are marked *