/ Published in: PHP
This is a simple function that will take a folder path and remove all of its contents including files and directories.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function emptyDir($path) { // INITIALIZE THE DEBUG STRING $debugStr = ''; $debugStr .= "Deleting Contents Of: $path<br /><br />"; // PARSE THE FOLDER if ($file != "." && $file != "..") { // IF IT"S A FILE THEN DELETE IT $debugStr .= "Deleted File: ".$file."<br />"; } } else { // IT IS A DIRECTORY // CRAWL THROUGH THE DIRECTORY AND DELETE IT'S CONTENTS if ($file2 != "." && $file2 != "..") { $debugStr .= "Deleted File: $file/$file2<br />"; } } } } $debugStr .= "Directory: ".$file."<br />"; } } } } } return $debugStr; } ?>
URL: http://www.aristoworks.com