I’m having a blonde moment, here is my problem:
Break down:
I have an edit page for 5 images, when you click on the image it disappears and an upload new images box appears.I am now bashing my head against the wall the update of image code. I need some help on how to check whether an image has changed or not or if the image has been selected for delete and delete that image too.
So it goes like this Existing Image > Click to change or check box to delete, if changed then update new image and post echo saying imaged updated, if image has not changed then do nothing or do something if not changed and delete has been checked.
The block of code below would be duplicated for each image:
$image_new = "test_new_image"; // New file name
$image_hidden = "test_db_image"; // This is the existing image name in a hidden input
$image_db = "test_db_image"; // Image name in the DB
if ($image_hidden == $image_db) {
echo "leave image as is in the db<br>";
} elseif ($image_new != $image_db) {
echo "change image in the db and delete existing image<br>";
} else {
echo "New image!<br>";
}
Or if someone has some better code to do what I want would be even better.
If you know the image_name in the DB at this point, wouldn’t the hidden field value be the same? In that case should be enough comparing old_name and new_name like this: