Hi, how would you delete a folder on the click of a button including its contents, including the file that has the script to delete it. After it has been deleted it should redirect to the homepage of the site. And how you show that if a folder exists then echo something.

Thank You for any help in advance.

Here is some code I use. Just added the rmdir for you, I don't actually remove the directory. As you can see in good developer style I intend to use iterators some time in the future ;)

//removed unwanted photos
$tmpPhotoDir = DRB.'/photos/';

//todo: use iterator
$dir = glob($tmpPhotoDir.'*.jpg');
if ($dir){
    foreach($dir as $fileName){
        unlink($fileName);
    }
}
rmdir($tmpPhotoDir);

Found a stackoverflow link for your exists question

You should know how to echo ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.