0

So I have look through and directory exclude certain files, show files numbered with a delete button and need to write in a delete function to delete the directory and the files in it and not sure how that is written can someone provide an answer.

<?php
    $dir = './';
    $files = scandir($dir);
    sort($files);
    $count = -1 ;
    foreach ($files as $file) {
        $v_delete = "delete_".$count;
            if ($file != '.' && $file != '..' && $file != 'read.php') {
            $str_URL = "./".$file;
            echo "<tr>";
            echo "<td>";
            echo $count;
            echo "</td>";
            echo "<td>";
            echo $file;
            echo "</td>";            
            echo "<td>";
            echo "<form action='' method='post'><input type='submit' value='Delete' name='".$v_delete."'/></form>";
            if(isset($_POST[$v_delete])) {
            // Your php delete code here


            echo "delete file : ".$file;
            }
            echo "</td>";

        }
        $count++;
    }
?>

0 Answers0