Hello,
I am trying to delete a file using the unlink function from my website, and database.
MySQL works properly at removing the input in my database using:
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM files WHERE id=%s",
GetSQLValueString($_GET['id'], "int"));
mysql_select_db($database_Creative, $Creative);
$Result1 = mysql_query($deleteSQL, $Creative) or die(mysql_error());
$deleteGoTo = "content-files.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
So it deletes from my database properly, but doesn't delete my file from the server.
( The database field for my file is: 'File' )
So in basic cade I want to implement this:
$tmpfile = "../uploads/files/Jim.txt";
unlink($tmpfile);
So basically I need the two above codes fused together but I cannot seem to get them to work together to delete both the input in my database, and the file on the server.
Thank you for your help in advance!
I tried this but it didn't work:
$target_path = "../uploads/files/";
$tmpfile = $target_path . basename($_FILES['File']['name']);
unlink($tmpfile);