Removing files from a directory
| From: | Niklas Lampén | Date: | Thu, 23 Aug 2001 12:17:03 +0000 |
| Subject: | Removing files from a directory | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-64078@lists.php.net to get a copy of this message | ||
I'm trying to remove files from a directory. I have this code to do it:
This code is in a included file located at '/map/'. File including this code
is located at '/'. Files to be removed are located at '/map/'.
$Handle = opendir('map/');
while ($file = readdir($Handle)) {
if (substr($file, 0, 3) == "md_") {
$split = explode("_", $file);
if ((time() - $split[1]) > 300) {
unlink($file);
};
};
};
What this does is return a Internal Server Error! If add do
unlink("map/".$file); it returns file not found. What to do? What is wrong?
Niklas Lampén