title: php file upload - invalid MIME type?
body: <p>I have a script that uploads a file. It checks the mime-type (should be audio file) and then uploads it. The type seems to be recognized but it gives an "invalid file" output. Am I missing something obvious?</p>
  
  <pre><code>Upload: songname.mp3
  Type: audio/mpeg
  Size: 4.5997314453125 MB
  Invalid file 
  </code></pre>
  
  <p>And part of the script:</p>
  
  <pre><code>if ($_FILES["file"]["error"] &gt; 0)
    {
    echo "Error: " . $_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*1024)) . " MB&lt;br&gt;";
    }
    $allowedExts = array("gif", "jpeg", "jpg", "png");
  $extension = end(explode(".", $_FILES["file"]["name"]));
  if ((($_FILES["file"]["type"] == "audio/mpeg")
  || ($_FILES["file"]["type"] == "audio/x-mpeg")
  || ($_FILES["file"]["type"] == "audio/mp3")
  || ($_FILES["file"]["type"] == "audio/x-mp3")
  || ($_FILES["file"]["type"] == "audio/mpeg3")
  || ($_FILES["file"]["type"] == "audio/x-mpeg3")
  || ($_FILES["file"]["type"] == "audio/mpg")
  || ($_FILES["file"]["type"] == "audio/x-mpg")
  || ($_FILES["file"]["type"] == "audio/x-mpegaudio")
  || ($_FILES["file"]["type"] == "audio/wav")
  || ($_FILES["file"]["type"] == "audio/x-wav")
  || ($_FILES["file"]["type"] == "audio/ogg"))   
  &amp;&amp; ($_FILES["file"]["size"] &lt; 20000000)
  &amp;&amp; in_array($extension, $allowedExts))
    {;;
    if ($_FILES["file"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
      }
    else
      {//something
      }
  
      if (file_exists("../sites/default/files/dance/" . $_FILES["file"]["name"]))
        {
        echo $_FILES["file"]["name"] . " already exists. ";
        }
      else
        {
        move_uploaded_file($_FILES["file"]["tmp_name"],
        "../sites/default/files/dance/" . $_FILES["file"]["name"]);
        echo "Stored in: " . "../sites/default/files/dance/" . $_FILES["file"]["name"];
        }    
    }
  else
    {
    echo "Invalid file";
    }
  </code></pre>