I am trying to update user image in php and this is how my code looks.
$u_image = $_FILES['u_image']['name'];
$image_tmp = $_FILES['u_image']['tmp_name'];
move_uploaded_file($image_tmp, "user/user_images/$user_image");
The function is replacing the old default image with new one but it is not renaming the old photo file. As a result i have a new photo with old name extension and so no image display on html page.
before update [old file] ['oldname.jpg'] after update [new file] ['oldname.jpg']
You are using the wrong variable name:
move_uploaded_file($image_tmp, "user/user_images/$user_image");
should be changed to:
move_uploaded_file($image_tmp, "user/user_images/$u_image");