title: File upload in php for .JPG, .PNG Extensions
body: <p>I read <a href="https://stackoverflow.com/questions/16252903/image-uploader-jpg/16253193">Image uploader, capital letters in JPG extension doesn&#39;t work</a> but i need to upload .JPG files in my file uploading system. </p>
  
  <p>Here is my Code : </p>
  
  <pre><code>&lt;?php
  $allowedExts = array("gif", "jpeg", "jpg", "png" , "JPG");
  $temp = explode(".", $_FILES["file"]["name"]);
  $extension = end($temp);
  if ((($_FILES["file"]["type"] == "image/gif")
  || ($_FILES["file"]["type"] == "image/jpeg")
  || ($_FILES["file"]["type"] == "image/jpg")
  || ($_FILES["file"]["type"] == "image/JPG")
  || ($_FILES["file"]["type"] == "image/pjpeg")
  || ($_FILES["file"]["type"] == "image/x-png")
  || ($_FILES["file"]["type"] == "image/png"))
  &amp;&amp; ($_FILES["file"]["size"] &lt; 20000)
  &amp;&amp; in_array($extension, $allowedExts))
    {
    if ($_FILES["file"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
      }
    else
      {
      echo "Upload: " . $_FILES["file"]["name"] . "&lt;br&gt;";
      echo "Type: " . $_FILES["file"]["type"] . "&lt;br&gt;";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;";
      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;";
  
      if (file_exists("upload/" . $_FILES["file"]["name"]))
        {
        echo $_FILES["file"]["name"] . " already exists. ";
        }
      else
        {
        move_uploaded_file($_FILES["file"]["tmp_name"],
        "upload/" . $_FILES["file"]["name"]);
        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        }
      }
    }
  else
    {
    echo "Invalid file";
    }
  ?&gt;
  </code></pre>
  
  <p>How can i change my code to make <strong>.JPG, .PNG files</strong> upload to my the upload directory ?</p>
  
  <p>Error i am getting is invalid files if i choose .JPG files to upload.</p>
  
  <p>Crazy try : I can't even upload if i change my code like this.</p>
  
  <pre><code>$allowedExts = array("gif", "jpeg", "jpg", "png" , "JPG");
  || ($_FILES["file"]["type"] == "image/JPG")
  </code></pre>