title: Php upload image to directory
body: <p>Ive been experimenting with the upload capability of php, I have been looking at this tutorial on w3school.</p>
  
  <pre><code>http://www.w3schools.com/php/php_file_upload.asp
  
  I installed this script on MYDOMAIN.com/New.html
  
  
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;form action="upload_file.php" method="post"
  enctype="multipart/form-data"&gt;
  &lt;label for="file"&gt;Filename:&lt;/label&gt;
  &lt;input type="file" name="file" id="file"&gt;&lt;br&gt;
  &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And then I put this snippet on MYDOMAIN.com/upload_file.php</p>
  
  <pre><code>&lt;?php
  $allowedExts = array("jpg", "jpeg", "gif", "png");
  $extension = end(explode(".", $_FILES["file"]["name"]));
  if ((($_FILES["file"]["type"] == "image/gif")
  || ($_FILES["file"]["type"] == "image/jpeg")
  || ($_FILES["file"]["type"] == "image/png")
  || ($_FILES["file"]["type"] == "image/pjpeg"))
  &amp;&amp; ($_FILES["file"]["size"] &lt; 20000)
  &amp;&amp; in_array($extension, $allowedExts))
    {
    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) . " kB&lt;br&gt;";
      echo "Stored in: " . $_FILES["file"]["tmp_name"];
      }
    }
  else
    {
    echo "Invalid file";
    }
  ?&gt;
  </code></pre>
  
  <p>Now there is a very high chance that im just a really confused person but what I assume that is suppose to do is take the file I put into the New.html file and if it is a image file upload it onto my directory but instead its just outputting Invalid file  Im not sure what to do any help is great hope to hear back soon thank you</p>