Clear And Delete The Folder After The Time Specified In

[Solved] Clear And Delete The Folder After The Time Specified In | Php - Code Explorer | yomemimo.com
Question : Clear and delete the folder after the time specified in php

Answered by : akbarali

<?
$days = 1;
$dir = dirname ( __FILE__ );
$nofiles = 0; if ($handle = opendir($dir)) { while (( $file = readdir($handle)) !== false ) { if ( $file == '.' || $file == '..' || is_dir($dir.'/'.$file) ) { continue; } if ((time() - filemtime($dir.'/'.$file)) > ($days *86400)) { $nofiles++; unlink($dir.'/'.$file); } } closedir($handle); echo "Total files deleted: $nofiles \n";
}
?>

Source : https://stackoverflow.com/questions/1921466/auto-delete-all-files-after-x-time | Last Update : Fri, 14 Aug 20

Answers related to clear and delete the folder after the time specified in php

Code Explorer Popular Question For Php