The ‘unlink()’ method is executed even though no images have been uploaded, why is this and how can I fix it?
If (isset($_FILES["image"]["name"])) {
move_uploaded_file($_FILES["imageUp"]["tmp_name"],
"C:/xampp/htdocs/" . $_FILES["image"]["name"]);
//if (file_exists($delete)) {
unlink($delete);
}
else {
$img = $data['row']->image_name;
}
//}
will always be set even if you upload a file or not.
issetchecks whether the thing is set or not. So it will always betrue.So you need to change your code :
Please try with this. Hope this helps 🙂