HTML interesse |
|
probeer eens iets met
<?php
function removeDir($path) {
// Add trailing slash to $path if one is not there
if (substr($path, -1, 1) != "/") {
$path .= "/";
}
foreach (glob($path . "*") as $file) {
if (is_file($file) === TRUE) {
// Remove each file in this Directory
unlink($file);
echo "Removed File: " . $file . "<br>";
}
else if (is_dir($file) === TRUE) {
// If this Directory contains a Subdirectory, run this Function on it
removeDir($file);
}
}
// Remove Directory once Files have been removed (If Exists)
if (is_dir($path) === TRUE) {
rmdir($path);
echo "<br>Removed Directory: " . $path . "<br><br>";
}
}
?>
<?php function removeDir($path) { // Add trailing slash to $path if one is not there if (substr($path, -1, 1) != "/") { $path .= "/"; } foreach (glob($path . "*") as $file) { // Remove each file in this Directory echo "Removed File: " . $file . "<br>"; } else if (is_dir($file) === TRUE) { // If this Directory contains a Subdirectory, run this Function on it removeDir($file); } } // Remove Directory once Files have been removed (If Exists) echo "<br>Removed Directory: " . $path . "<br><br>"; } } ?>
dus iets met glob() dat dus in een loopje zetten zodat hij alle bestanden verwijderd. En op het laatste de map verwijderen.
ps. kon je gewoon vinden bij http://nl3.php.net/manual/nl/function.rmdir.php tussen de reacties |