PHP - MySQL how to delete an image when a user submits a new image problem.
- by pc-wiki
I'm trying to delete the current image that is already set on the server when a user submits a new image to the server, but I don't know how to do add this to my current code can some one please help me?
Here is my PHP & MySQL code.
if(isset($_FILES["thumb"]["name"])) {
if (file_exists("/images/" . $_FILES["thumb"]["name"])) {
$thumb != $_FILES["thumb"]["name"];
} else if($_FILES["thumb"]["name"] == TRUE) {
move_uploaded_file($_FILES["thumb"]["tmp_name"],
"/images/" . mysqli_real_escape_string($mysqli, htmlentities(strip_tags(basename($_FILES["thumb"]["name"])))));
$thumb = mysqli_real_escape_string($mysqli, htmlentities(strip_tags(basename($_FILES["thumb"]["name"]))));
}
if($thumb == TRUE) {
//create thumb code here...
}
}