I want the user to be able to delete a file by clicking on a checkbox and submitting the form.
Somewhere in the header:
foreach ($_POST ['files'] ['deleteFile'] as $value)
{
unlink ($value);
$fileError = '¡Éxito!';
}
Somewhere in the body:
<form enctype="multipart/form-data" method="post" name="files">
<!-- No action attribute was added as the form is processed in the same file -->
<?php
foreach (glob ('files/*.*') as $file)
{
echo $file . '<input name="deleteFile" type="checkbox" value="' . $file . '">';
}
?>
<input type="submit" value="Confirmar">
</form>