On 05/03/07, Muhammad Waqas <[EMAIL PROTECTED]> wrote: > > > Hello Experts, > So far i m using following code for deleting folders and files.But it will > only delete those folders which r empty.I want to delete those folders also > which has some files.pls give me the solution > > > Thanks, > Waqas > <http://www.youngcoders.com/editpost.php?do=editpost&p=115815> >
Hey Waqas, What you're doing there looks good. I think the best way I can suggest is to write a recursive routine to remove the contents of a folder. If you are struggling with writing the function some people have left examples of both recursive and iterative functions in the contributed notes at http://www.php.net/manual/en/function.rmdir.php A method you could use, but I would try to avoid, would be to ask the operating system to remove the directory. On unix you would use exec('rm -rf dir'); // replace dir with the dirname This is not safe as it can do real damage to the system if you get the dir wrong, and also would not work on non unix-based systems. When safe mode is enabled in PHP exec will only run executables that are within the safe_mode_exec_dir to provide some extra security. If you do consider this option make sure you read the warnings in the manual <http://uk.php.net/manual/en/function.exec.php> first. Phill
