php image type detection
<p>Unable to detect mime type. if I remove <code>($mime=="image/jpeg" || $mime=="image/pjpeg")</code>, it could upload the image successfully.</p>

<pre><code>$mime = $_FILES['Filedata']['type'];
if((!empty($_FILES['Filedata']['tmp_name'])) &amp;&amp; ($_FILES['Filedata']['error'] == 0)) {
  $filename = basename($_FILES['Filedata']['name']);
  $ext = pathinfo($filename, PATHINFO_EXTENSION);
  if (($ext=="jpg" || $ext=="jpeg") &amp;&amp; ($mime=="image/jpeg" || $mime=="image/pjpeg") &amp;&amp; ($_FILES["Filedata"]["size"] &lt; 350000)) {
        $newname = $filename;
        if (!file_exists($newname)) {
            if (move_uploaded_file($_FILES['Filedata']['tmp_name'], "./photo/" . $newname)) {
                echo "It's done! The file has been saved as: ".$newname;
            } else {
                echo "Error: A problem occurred during file upload!";
            }
        } else {echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";}
  } else {
     echo "Error: Only .jpg images under 350Kb are accepted for upload";
  }
} else {
    echo "Error: No file uploaded";
}
</code></pre>
