Cheers Iain,
Ok, that worked (and my eyes lit up!), but for some reason, it only worked on the files which were already uploaded. So I deleted them - great, but then when I uploaded another file and tried to delete that, it didnt delete.
Im new to php so is this somethign you know of and how to fix, cos to me, it doesnt actually make any sense why one file uploaded yesterday deleted fine, but anything I upload today - will not??
This is my code so far:
function DeleteFile($UseFolder,$filename) {
if (file_exists("${UseFolder}/${filename}")) {
return unlink("${UseFolder}/${filename}");
}
return FALSE;
}
switch($GET[action]) {
case "deletefile":
$filename = $GET[filename];
$UseFolder = $_GET[UseFolder];
$success=DeleteFile($UseFolder,$filename);
break;
default:
break;
}
And then this is the main bit:
if (!file_exists("$UseFolder/$filename"))
{
echo "
<a href=\"index.php?action=deletefile&filename=$filename&directory=$UseFolder&\">
<img src=\"images/delete.gif\" border=\"0\"></a>";
}
else
{
if (file_exists("$UseFolder/$filename"))
{
echo "
<a href=\"index.php?action=deletedir&filename=$filename&directory=$UseFolder&\">
<img src=\"images/delete.gif\" border=\"0\"></a>";
}
}
if(empty($directory)) {
$UseFolder = "userfiles";
} else {
$UseFolder = "userfiles/$directory";
}
echo "<a target=\"blank\" href=\"$UseFolder/$filename\">
<img src=\"images/download.gif\" alt=\"$mess[23]\" width=\"20\" height=\"20\" border=\"0\"></a>";
Right, can you see anything wrong in there?
Again, thanks in advance😕