title: Get content of file uploaded by user before saving
body: <p>See, I provide the users of my website the possibility of upload their own PHP/HTML/TXT files into my server, right?... But I want to get that file content without saving it in my server and save the content into a string, or whatever.</p>
  
  <p>It is possible to do that?... If not, what should I do to get the content after saving the file in my server?... please, help me!</p>
  
  <p>I don't know if this can help, but this is the code I use to upload the user files.</p>
  
  <pre><code>$allowedExts = array("php", "html", "txt");
  $tmp = explode(".", $_FILES["file"]["name"]);
  $extension = end($tmp);
  
  if 
  ((($_FILES["file"]["type"] == "application/octet-stream") 
  || ($_FILES["file"]["type"] == "text/php") 
  || ($_FILES["file"]["type"] == "text/html") 
  || ($_FILES["file"]["type"] == "text/plain")) 
  &amp;&amp; ($_FILES["file"]["size"] &lt; 50000) &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";
  }
  </code></pre>