$allowedExts = array("gif", "jpeg", "jpg", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
This is checked twice because, the extension of the file and 'file type' can be differ, so someone can not upload executable file with .png extension.
In your modified code, it is possible to upload a different type of file with modified extension. like they can upload word document with '.png' extension.
Your new code is just checking extension and don't have double check.