Im setting up a website like gumtree (uni project). I'm implementing the ability for users to be able to edit their listed items. I'm having trouble with the image part. If the user does not want to change the image when updating other rows, the ran function is overwriting the image with random numbers. I have attached a picture of the code.
I want the user to be able to update things like the product name and price without the image being overwritten by random numbers each time they press the update button.
if(isset($_FILES['uploadimg']['name'])){
$ran = rand(0,1000000);
$filename = $_FILES['uploadimg']['name'];
$filename = $ran.$filename;
$filetmp = $_FILES['uploadimg']['tmp_name'];
$filetype = $_FILES['uploadimg']['type'];
move_uploaded_file($filetmp, "../dbimages/".$filename);
$updateimg = "UPDATE elmtree SET path='$filename' WHERE itemid='$id'";
$imageupdate = $conn -> query($updateimg);
}