I've asked this question before but approached a different solution/version thanks to this.
To grant some insight on the webapplication, I'll quote it here:
As for an assignment I created a filter that modifies a Config that's connected to an API which prints out Order files. The web application has the option to save the modified Orderlist with a date and number added to it.
The output of the modified order list:
Order 25-01-21 Versie 1.xml
Order 26-01-21 Versie 1.xml
Order 26-01-21 Versie 2.xml
Order 26-01-21 Versie 3.xml
Order 26-01-21 Versie 4.xml
I've been asked to add a tool that allows him to delete a file, if he wishes to. With some struggling, looking around and an amazing approach that's been given in the question I asked before I came to this:
<?php
$dir = '..\api-ivolved\s_orderlist';
$ar=glob($dir); // Change this input
foreach(glob("*.xml") as $filename) {
echo "<input type=\"checkbox\" name=\"files[]\" value=".$filename."/>" . htmlspecialchars($filename) . "<br />"; }
if (isset($_GET['delete'])){
// Make sure files are checked/marked for deletion.
if (!empty($_GET['files[]'])) {
// Loop through each file and delete
foreach ($_GET['files[]'] as $file) {
unlink($file);
}
}
}
?>
<form class="deleteFile" method="get" enctype="multipart/form-data">
<br />
<strong> Delete checked files? </strong> <input type="checkbox" name="delete" value="1"/><br/>
<input type="submit" id="delete" value="Delete file"/>
</form>
Now the issue is that after I check a file checkbox and confirmation to delete the file, the document still remains in the folder. Can someone point out or give me an example how I can fix this issue?