> How do i delete all file in a directory???
> 

You could use a function like this:
(html code at end)


function delFiles($filter, $sDir) {
$cDirectory = includeTrailingSlash($sDir);

$handle = opendir($cDirectory);
while ($file = readdir($handle)) 
        {
                if ($file == '.' || $file == '..') 
                        {
                continue;
                }
                if (is_dir($cDirectory . $file)) 
                 {                              
                 echo "ignoring $cDirectory$file <br />";
                delFiles($filter, $cDirectory . $file);
                        continue;
                }
                
                if (eregi($filter, $file)) 
                 {

                echo " <em>deleting $cDirectory$file</em> <br />";
      unlink($cDirectory . $file);
                 
                }
        }
  closedir($handle);
}

function includeTrailingSlash($path) 
        {
                if (!eregi("/$", $path)) 
                        {
                        $path .= "/";
                        }
                return $path;
        }

// delete all the .htm files in this directory and it's sub directories

$sDir="the directory you want to delete files in";

delFiles("\.htm$", $sDir);

//where\.htm$ is the filter you are applying

echo "done deleting old files <br />";


hth

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to