'Could not get image extension

On the database, the name of the image being saved always ended with just "." (example: 872187812.) . The extension is missing. Please help. Thanks a lot.

<?php
   $id=$_GET['id'];
   $name=$_POST['name'];
   $description=$_POST['description'];
   $pic = $_FILES["image"]["name"];

   $temp = explode(".", $_FILES["image"]["name"]);
   $newfilename = date("YmdH").round(microtime(true)). '.'.end($temp);
   move_uploaded_file ($_FILES["image"]["tmp_name"], "symptoms/" . $newfilename);

if ($_FILES["image"]["name"]!="")
{
   mysqli_query($con,"update symptoms set image = '$newfilename', name='$name', description='$description' where id='$id'")or die(mysqli_error());
}

else
{
   mysqli_query($con,"update symptoms set image = '$newfilename', name='$name', description='$description' where id='$id'")or die(mysqli_error());
}
?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source