i think this question was asked few times, which I have went through and was using some of the code from the net. Right now Im encountering problem with the time.
Let me furnish the code first:
<?php
$pathToDir = getcwd();
$pathToFilesDir = $pathToDir . '\files';
$pathToFiles = $pathToFilesDir . '\\';
if ($handle = opendir($pathToFilesDir)) {
while (false !== ($file = readdir($handle))) {
$filelastmodified = filemtime($file);
if ($file != '.' && $file != '..'){
if((time() - $filelastmodified) > 60 && is_file($file)){
unlink($pathToFiles . $file);
}
}
}
closedir($handle);
}
?>
This was what I was trying, to auto delete the files which are one minute older. Just for testing purposes I was trying for one minute. The result is that the files dont get deleted. On the other hand I just removed this timing condition
if((time() - $filelastmodified) > 60 && is_file($file))
and ran the script, which could delete the files immediately.
Can any one spot the mistake which I am making?
Thanks Raaks