<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">PHP - Dynamically Remove Folder</h3> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-6"> <table class="table table-bordered"> <thead class="alert-info"> <tr> <th>Folder Name</th> <th>Action</th> </tr> </thead> <tbody style="background-color:#fff;"> <?php foreach ($files as $file){ if($file != '.' && $file !='..'){ ?> <tr> <td><?php echo $file?></td> <td><a class="btn btn-danger" href="remove.php?folder=<?php echo $file?>"><span class="glyphicon glyphicon-trash"></span> Remove</a></td> </tr> <?php } } ?> </tbody> </table> </div> </div> </body> </html>
<?php function removeDir($dir) { foreach ($items as $item) { if ($item === '.' || $item === '..') { continue; } $path = $dir.'/'.$item; xrmdir($path); } else { } } } $folder = $_REQUEST['folder']; removeDir("files/".$folder); } } ?>