PHP is not recognizing file upload extension : <p>I have the following array sent by ajax when echoed in php</p>

<pre><code>[file] =&gt; Array
    (  [name] =&gt; XXXX.jpg    [type] =&gt; image/jpeg   [tmp_name] =&gt; D:\xampp\tmp\phpC5F2.tmp
        [error] =&gt; 0    [size] =&gt; 25245     )
</code></pre>

<p>and the following code to process the upload:</p>

<pre><code>if(isset($_FILES['file'])) {
 $natid = '9999';
 $target_dir = "../uploads/";
 $fname = $_FILES['file']['name'];
 $target_file = $target_dir . $natid .'/'. $fname;
 $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));            

  if($imageFileType == "jpg" &amp;&amp; $imageFileType == "png" &amp;&amp; $imageFileType == "jpeg" &amp;&amp; $imageFileType == "gif") {
    $check = getimagesize($_FILES["file"]["tmp_name"]); 
        if($check !== false) {  //  !== not equal
            echo "File is an image - " . $check["mime"] . ".&lt;br&gt;";
        } else {
            echo "the file is not an image.";
        }
  } elseif ($imageFileType == "pdf"){
    echo "File is a PDF - " . $check["mime"] . ".&lt;br&gt;";
  } else {
    echo "Sorry, only PDF, JPG, JPEG, PNG &amp; GIF files are allowed.";
  }
}
</code></pre>

<p>When I run the code I get the reply from php saying that file is neither an image nor a PDF although </p>

<blockquote>
  <p>$imageFileType gives me 'jpg'</p>
</blockquote>
