title: PHP video upload and checking video type
body: <p>I created my upload file with video size and type validation. Only webm, mp4 and ogv file types are allowed and 2gb file size max. My php code:</p>
  <pre><code>if (isset($_POST['submit']))
  {
      $file_name = $_FILES['file']['name'];
      $file_type = $_FILES['file']['type'];
      $file_size = $_FILES['file']['size'];
  
      $allowed_extensions = array(&quot;webm&quot;, &quot;mp4&quot;, &quot;ogv&quot;);
      $file_name_temp = explode(&quot;.&quot;, $file_name);
      $extension = end($file_name_temp);
      
      $file_size_max = 2147483648;
      if (!empty($file_name))
      {
          if (($file_type == &quot;video/webm&quot;) || ($file_type == &quot;video/mp4&quot;) || ($file_type == &quot;video/ogv&quot;) &amp;&amp;
              ($file_size &lt; $file_size_max) &amp;&amp; in_array($extension, $allowed_extensions))
          {
              if ($_FILES['file']['error'] &gt; 0)
              {
                  echo &quot;Unexpected error occured, please try again later.&quot;;
              } else {
                  if (file_exists(&quot;secure/&quot;.$file_name))
                  {
                      echo $file_name.&quot; already exists.&quot;;
                  } else {
                      move_uploaded_file($_FILES[&quot;file&quot;][&quot;tmp_name&quot;], &quot;secure/&quot;.$file_name);
                      echo &quot;Stored in: &quot; . &quot;secure/&quot;.$file_name;
                  }
              }
          } else {
              echo &quot;Invalid video format.&quot;;
          }
      } else {
          echo &quot;Please select a video to upload.&quot;;
      }
  }
  </code></pre>
  <p>My html code:</p>
  <pre><code>&lt;form action=&quot;upload_file.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
  &lt;input type=&quot;file&quot; name=&quot;file&quot;&gt;&lt;br /&gt;
  &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I'am always getting &quot;Invalid video format.&quot;. I downloaded webm, mp4 and ogv video files from flowplayer website to test my little upload script.</p>
  <pre><code>http://stream.flowplayer.org/bauhaus/624x260.webm
  http://stream.flowplayer.org/bauhaus/624x260.mp4
  http://stream.flowplayer.org/bauhaus/624x260.ogv
  </code></pre>