I am listing the text files that I have on my server, and I want to add a link to download that file and/or delete it.
It works perfectly, but the problem is that when I press the delete button it deletes the file and opens a new page, and what I want is that when I press the delete button, deletes the file and refresh the page.
This is my code:
$user = $_SESSION['email'];
$direc = "./WSN/" . $user;
$directorio = opendir($direc); //current route
$vacio = true;
while ($archivo = readdir($directorio)) //get a file and then another on
{
if (($archivo!=".")&&($archivo!=".."))//check whether or not a directory
{
echo "
<b>
<a href=\"".$direc."/".$archivo."\" target=\"_blank\">".$archivo."</a>
</b>
-
<b>
<a href=\"include/download.php?file=.".$direc."/".$archivo."\" title='download'>Download</a>
</b>
-
<b>
<a href=\"include/delete.php?file=.".$direc."/".$archivo."\" title='delete'>Delete</a>
</b>
<br />
";
$vacio = false;
}
}
And this is the code of delete.php:
$file = $_GET['file'];
unlink($file);
Someone can help me?
[Edit]: "abreuna" means "opens one".