#How to delete files by time in PHP?
First use the function "opendir()" to read all files in the folder; then use the function "is_dir()" to filter out the folder; then use the function "filemtime()" to get the file creation time; finally delete it according to the creation time.
Code example
$n) unlink($fullpath); //删除文件 } } } } closedir($dh); } } //下面是调用的代码 //删除1天前的文件 $dir = realpath('./Upload/export'); del_file_by_ctime($dir, 24*60); ?>
Recommended tutorial: "PHP"
The above is the detailed content of How to delete files by time in PHP?. For more information, please follow other related articles on the PHP Chinese website!