<?php
function remove_directory($directory) {
if (is_dir($directory) === true) {
$contents = scandir($directory);
unset($contents[0], $contents[1]);
foreach($contents as $object) {
$current_object = $directory.'/'.$object;
if (filetype($current_object) === 'dir') {
remove_directory($current_object);
} else {
unlink($current_object);
}
}
rmdir($directory);
}
}
?>
<h1>DELETE</h1>
<form action="" method="get">
<?php if (isset($_GET['delete']) === true) {
remove_directory('files/folder'); / when I click that submit button must delete only 'folder' not all 'folder1' and 'folder2'
}
?>
<input type="submit" name="delete"/>
</form>
<form action="" method="get">
<?php if (isset($_GET['delete']) === true) {
remove_directory('files/folder1'); // when I click that submit button must delete only 'folder1'
}
?>
<input type="submit" name="delete"/>
</form>
<form action="" method="get">
<?php if (isset($_GET['delete']) === true) {
remove_directory('files/folder2'); // when I click that submit button must delete only 'folder2'
}
?>
<input type="submit" name="delete"/>
</form>
当我单击提交按钮时,我只想删除提交的文件。但是当我现在单击提交按钮时,它会删除目录中的所有文件,而不是提交...当我单击第一个按钮时,我必须只删除“文件/文件夹”而不是全部...我怎么能得到那个????我有一个函数remove_directory。我知道我的程序带有 $_GET 变量,但我不知道如何修复它。但是现在当我单击一个提交按钮时,删除所有文件夹 - 文件夹、文件夹 1 和文件夹 2 问题出在哪里或如何解决?