I have this php to upload a file, I want add a button at the right of each element of the list where if I click on I delete the element from the list and from the server. Is it possible? Thanks
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
Select a file to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Load" name="submit">
</form>
<div>
<?php
$dir = 'up/';
$files = scandir($dir);
echo 'uploaded files<br><hr>';
$i = 1;
foreach ($files as $key)
{
if ($i>2)
{
$j = $i-2;
echo $j."  <a href='up/".$key."'>".$key."</a><hr>";
}
$i++;
}
echo ' ';
?>
</div>
</body>
</html>
<?php
if (isset($_POST['submit']))
{
echo '<center><h1>upload succesful!</h1></center>';
$structure = 'up/';
$target_file = $structure.basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
}
?>