title: Wordpress custom file upload in page
body: <p>I'm currently using this code for PHP file upload (found directly on the wordpress page):</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="upload.php" method="POST"&gt;
  Please choose a file: &lt;input name="uploaded" type="file" /&gt;&lt;br /&gt;
  &lt;input type="submit" value="Upload" /&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>upload.php</p>
  
  <pre><code>    $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 "Return Code: " . $_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 "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br&gt;";
  
              if (file_exists("upload/" . $_FILES["file"]["name"]))
              {
                  echo $_FILES["file"]["name"] . " already exists. ";
              }
              else
              {
                  move_uploaded_file($_FILES["file"]["tmp_name"],
                                     "upload/" . $_FILES["file"]["name"]);
                  echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
              }
          }
      }
      else
      {
          echo "Invalid file";
      }
  </code></pre>
  
  <p>It always returns "invalid file" even when I know 100% it should work.</p>
  
  <p>I've been looking around online and I think that WP cannot do enctype="multipart/form-data" so that's why it doesn't work.</p>
  
  <p>Does anyone have a work around or any idea why this won't work?</p>