我有一个金发的时刻,这是我的问题:
分解:
我有一个 5 张图片的编辑页面,当你点击图片时,它会消失并出现一个上传新图片框。我现在正在为图像代码的更新撞墙。我需要一些帮助来检查图像是否已更改,或者图像是否已被选择删除并删除该图像。
所以它就像这样现有图像>单击以更改或复选框以删除,如果更改则更新新图像并发布回声说图像已更新,如果图像未更改则不执行任何操作或执行某些操作,如果未更改并且已检查删除。
下面的代码块将为每个图像复制:
$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>";
}
或者,如果有人有更好的代码来做我想做的事情会更好。