title: PHP File Upload with Apache Linux Server
body: <p>I am having trouble uploading a file to my server. I am using another computer on my network at act as my server running Linux using Apache. I am trying to upload pdf files to my server but no matter what size or the name of the file I can not get a file to upload. When I <code>echo $_SERVER['DOCUMENT_ROOT']</code> I get <code>/var/www</code>. My folder structured would be <code>var/www/phpfiles/uploads</code>. The files <code>addentry.php</code>, <code>phpupload.php</code> and <code>test.php</code> are all in this path <code>var/www/phpfiles</code>.</p>
  
  <p>When I upload a file I get the correct file name, size and tmp echoed, but I do not get "Uploaded" or "Root Uploaded" echoed, and the file is not moved to <code>var/www/phpfiles/uploads</code>. Any help would be greatly appreciated.</p>
  
  <p>addentry.php</p>
  
  <pre><code>&lt;div id="uploadPDF"&gt;
      &lt;iframe id="iframe_display" src="test.php" width="400" height="100"&gt;
  
      &lt;/iframe&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>phpupload.php</p>
  
  <pre><code>$tempName = $_POST[instrumentPDF];
  $fileSize = $_FILES['instrumentPDF']['size'];
  $fileType = $_FILES['instrumentPDF']['type'];
  $fileName = $_FILES['instrumentPDF']['name'];
  $tmp_name  = $_FILES['instrumentPDF']['tmp_name'];
  
  echo ("file size: " . $fileSize  . "&lt;br&gt;");
      echo ("&lt;br&gt;");
      echo ("file name: " . $fileName . "&lt;br&gt;");
      echo ("&lt;br&gt;");
      echo ("pdf Test: " . $pdfTest . "&lt;br&gt;");
      echo ("&lt;br&gt;");
      echo ("pdf Temp_Name: " . $tmp_name . "&lt;br&gt;");
  
  if(move_uploaded_file($tmp_name, "uploads/" . $fileName)){
      echo ("&lt;br&gt;");
      echo ("Uploaded");
      echo ("&lt;br&gt;");
  }
  
  if(move_uploaded_file($tmp_name, $_SERVER['DOCUMENT_ROOT']."/uploads/".$fileName)){
      echo ("&lt;br&gt;");
      echo ("Root Uploaded");
      echo ("&lt;br&gt;");
  }
  </code></pre>
  
  <p>test.php</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="POST" action="phpupload.php" name="aform" id="PDFform"&gt;
      &lt;table width="300" height="25" border="1"&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;label&gt;Instrument (only pdf)&lt;/label&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="104857600" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input name="instrumentPDF" type="file"  onchange="check_file()"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input name="Submit" type="Submit" align="absmiddle" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>