help everyone!.i want a php script that auto delete files more than 50 days on my website.thanks
auto delete files more than 50 days
Collapse
X
-
By amylee:
PHP Code:$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
Comment
-
Originally posted by arnage View PostBy amylee:
PHP Code:$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
Comment
Comment