title: Displaying an uploaded file from $_FILES
body: <p>I'm having some issues with uploading files from HTML to a PHP based web server. 
  The following is my HTML code. No issues here I believe. </p>
  
  <pre><code>&lt;html&gt;
   &lt;body&gt;
  
    &lt;form action="upload.php" method="post"
     enctype="multipart/form-data" action="2.2.2.cgi"&gt;
     &lt;input type="file" name="file" id="file" size="35"&gt;&lt;br&gt;
     &lt;input type="submit" name="submit" id="submit" value="Submit"&gt;
    &lt;/form&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP code: </p>
  
  <pre><code>&lt;?php
  
  define ('MAX_FILE_SIZE', 1000000);
  
  $permitted = array('image/gif', 'image/jpeg', 'image/png', 'image/pjpeg', 'text/plain');
  
  if  ($_FILES['file']['type'] == $permitted 
      &amp;&amp; $_FILES['file']['size'] &gt; 0 
      &amp;&amp; $_FILES['file']['size'] &lt;= MAX_FILE_SIZE) {
        move_uploaded_file($_FILES, $uploadedfile);
        echo ('&lt;img src="'.$uploadedfile'" /&gt;');
  }
  ?&gt;
  </code></pre>
  
  <p>I can't figure out how to make it work in PHP. I've been trying several different ways and the above code is just my latest desperate attempt at figuring it out by trying to store the value into a new variable. What I want to do is the following: </p>
  
  <ul>
  <li>Restrict the type and size of files that can be uploaded. </li>
  <li>Is the file a picture? Display the picture.</li>
  <li>Is it a plaintext file? Display the contents of the file.</li>
  <li>Is it an unpermitted file? Display the name, type and size of the file.</li>
  </ul>
  
  <p>Any kind of hint or help in any way would be greatly appreciated. Thanks! </p>
  
  <p>PS. It's not going live, so any security issues are irrelevant at the moment.</p>