I have a bunch of files that I show on the page from folder, and every file has a button to delete it from the folder, I'm using hidden input to get the file name and to link it with path to delete it. This hidden input changes with each file I want to delete. How can I get the first item of $_POST array to link it with path to delete the file? This is my code:
<form action="deleteFile.php" method="POST">
<input type="hidden" name="<?php echo $file ?>">
<button type="submit" name="deleteFile" class="delete"><i class="far fa-trash-alt"></i></button>
</form>
and this is the deleteFile.php:
$curret_path = $_SESSION['folder_path'];
if (isset($_POST['deleteFile'])) {
$fileName = $_POST[0];
unlink($curret_path . '/' . $fileName);
}