Here my script
Code: Select all
<html>
<head>
<meta http-equiv='refresh' content='180'>
</head>
<body>
<?php
///////////////
$minutes = '15'; ///Minute that delete file if this minute past its last modify
$dir_name="/opt/lampp/htdocs/try/tmp"; ///dir name you want to use like temp !and dont but "/" to end!
//////////////
$dir = opendir($dir_name);
while ( gettype ( $filename2 = readdir($dir)) != boolean )
{
$filename=$dir_name."/".$filename2;
if (is_dir($filename)) {continue;}
echo "$filename was change: " . date ("i", filemtime($filename))."<br>"; ///You can delete this line
echo "And now: ".date ("i")."<br>"; ///You can delete this line
if(date("i")-date("i", filemtime($filename)) >= $minutes or date("i") < date("i", filemtime($filename)))
{
if(unlink($filename)){echo $filename." deleted<br>";} else {echo "There is some eror and ".$filename." could not be deleted!";}
}
}
?>
</body>
</html>While its open any browser you can use some dir like tmp.
If you have any questions please ask..