When a user uploads a photo, it checks to see if they already have one; and if they do I want it to delete the old one (which could have any extension) and then put the new one. Is there a way to do that without getting the old extension from the database? Code at the moment:
$del = $members->prepare("insert into profiles(userid, path, width, height, type, rtu, ext) values(?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE path = ?, width = ?, height = ?, type = ?, rtu = ?, ext = ?, time = NOW()");
$del->bind_param('sssssssssssss', $_SESSION['token'], $title, $file_info[0], $file_info[1], $file_info[2], $rh, $extension,
$title, $file_info[0], $file_info[1], $file_info[2], $rh, $extension);
$del->execute();
$new_file_name = "bb-x".$_SESSION['token'].".".$extension;
if ($del->affected_rows > 0) {
unlink('profiles/bb-x62'<any extension>);
}
$move_file = move_uploaded_file($file['tmp_name'], $upload_image_to_folder.$new_file_name);