Copy code The code is as follows:
//delfile("upload",10);
function delfile($dir,$n) //Delete all files created N minutes ago under the DIR path;
{
if(is_dir($dir))
{
if($dh =opendir($dir))
{
while (false !== ($file = readdir($dh)))
{
if($file!="." && $file !="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath))
{
//$filedate =date("Y-m-d", filemtime($fullpath));
$filedate=date("Y-m-d h:i:s", filemtime($fullpath));
//$d1=strtotime(date( "Y-m-d"));
$d1=strtotime(date("Y-m-d h:i:s"));
$d2=strtotime($filedate);
//$Days=round(( $d1-$d2)/3600/24);
$Days=round(($d1-$d2)/60);
if($Days>$n)
unlink($fullpath) ; ////Delete files
}
}
}
closedir($dh);
}
}
?>
http://www.bkjia.com/PHPjc/328190.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328190.htmlTechArticleCopy the code as follows: ?php //delfile("upload",10); function delfile($dir, $n) //Delete all files created N minutes ago in the DIR path; { if(is_dir($dir)) { if($dh=opendir($dir))...