auto delete files more than 50 days
Started on the old forum in June 2013 · view the original in the archive · old links redirect here
By amylee:
$path = dirname(__FILE__).'/files';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filectime($path.'/'.$file)) < 86400) { // auto-deletion every 24 hours
if (strripos($file, '.txt') !== false) { //deletes particular file extension
unlink($path.'/'.$file);
}
}
}
}
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
arnage wrote: By amylee:
$path = dirname(__FILE__).'/files'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ((time()-filectime($path.'/'.$file)) < 86400) { // auto-deletion every 24 hours if (strripos($file, '.txt') !== false) { //deletes particular file extension unlink($path.'/'.$file); } } } }
Thanks guys..seems cron job is simpler,bt i stil find this code useful..thanks
Busary wrote: Thanks guys..seems cron job is simpler,bt i stil find this code useful..thanks
make a new cron job as like get delete.php (delete.php is the file which include the code)