Help me n tell me.
How 2 set auto delet file in directory in x minut
Collapse
X
-
PHP Code:$path = dirname(__FILE__).'/files';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filectime($path.'/'.$file)) < 86400) { // auto-deletion every 24 hours
if (strripos($file, '.txt') !== false) { //deletes particular file extension
unlink($path.'/'.$file);
}
}
}
}
-
Originally posted by amylee View PostPHP Code:$path = dirname(__FILE__).'/files';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filectime($path.'/'.$file)) < 86400) { // auto-deletion every 24 hours
if (strripos($file, '.txt') !== false) { //deletes particular file extension
unlink($path.'/'.$file);
}
}
}
}
Comment
-
Originally posted by amylee View Postyou asked how to do it and that's how its done
you havn't said what type of script you are using, what files you want removing
how do you expect anyone to help without any information
i have shown you a way to do it now try figuring it out
Comment
-
if you are deleting files that are not in the same directory as the script on some servers you will need to use chdir() eg:
PHP Code:$old = getcwd();
chdir("images");
unlink("something.else");
chdir($old);
you dont need loads of posts from me :PLast edited by something else; 25.03.12, 00:32.
Comment
Comment