deleting all one day old files from folder through php

deleting all one day old files from folder through php

If you want to find the old files from your system or server then you can use the following code. I used the following code for deleting the old files from system.

deleting all one day old files from folder through php


/*****************Get the path to Extension ****************/
$array_path = explode("/",$_SERVER['SCRIPT_FILENAME']);
<div id=":2e">$dynamic_path = "";
for ($i=0;$i
 if($array_path[$i]!="")
$dynamic_path =$dynamic_path."/".$array_path[$i];

// This linux command will delete the one day older from specific folder.
exec("find ".$dynamic_path."* -mtime +1 -exec rm {} \;");</pre>
<div>
For deleting the old files from system I used the Linux command. You can execute the command using the exec function.
If you want to use the Linux command then use the following command
# find /home/user/test/ -m

deleting all one day old files from folder through php
deleting all one day old files from folder through php

time +1 exec rm {}

Above code will only work in Linux server.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “deleting all one day old files from folder through php”

Leave a Reply

Your email address will not be published.