I already read it so many questions and answers about it but I can't still solve my problem...
I'm trying to create a function that deletes all the files with "xml" or "xsl" extension that has been created one day ago. But I'm getting this warning on each file I have:
Warning: filemtime() [function.filemtime]: stat failed for post_1003463425.xml in /home/u188867248/public_html/ampc/library.php on line 44
All the files of this directory have the same structure name "post_ + randomNum + .xml" (example: post_1003463425.xml or post_1456463425.xsl). So I think it's not an encoded problem (like I saw in other questions).
The code of my function is this:
function deleteOldFiles(){
if ($handle = opendir('./xml')) {
while (false !== ($file = readdir($handle))) {
if(preg_match("/^.*.(xml|xsl)$/i", $file)){
$filelastmodified = filemtime($file);
if ( (time()-$filelastmodified ) > 24*3600){
unlink($file);
}
}
}
closedir($handle);
}
}
Thanks for your help :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…