Page 1 of 1

Using some directory like temporary

Posted: Fri Jul 18, 2008 4:19 am
by irfan798
You can use it to any directory you want

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>
You can change <meta http-equiv='refresh' content='180'> 180 to what second you want the script work. Its looping

While its open any browser you can use some dir like tmp.

If you have any questions please ask..