title: In PHP, is it possible to upload files to the server?
body: <p>In PHP, is it possible to upload files to the server? If so, then how can I create an upload form and insert the files to a specific page? Any extension images: .jpeg .gif or files: .txt .pdf etc. I am using XAMPP (localhost to view my website).</p>
  
  <p>I have tried many tutorials, but there are lot of errors.</p>
  
  <p>This is this HTML file:</p>
  
  <pre><code>&lt;form action="fileupload.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;
  </code></pre>
  
  <p>And here is the PHP script:</p>
  
  <pre><code>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"];
  }
  </code></pre>
  
  <p>The result is shown like this:</p>
  
  <blockquote>
    <p>Upload: (file here)<br>
       Type: image/jpeg<br>
       Size: 757.521484375 Kb<br>
       Stored in: (temp file in C:)</p>
  </blockquote>
  
  <p>But whenever I find my file in the tmp folder. It's nowhere to be found.</p>