title: PHP - File Upload Fail
body: <p>I don't understand why this is not working. It should be very easy.</p>
  
  <p>upload.php :</p>
  
  <pre><code>$uploaddir = '/usr/share/nginx/www/pitfax/upload/'; 
  $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  
  echo "&lt;p&gt;";
  
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {   
      echo "File is valid, and was successfully uploaded.\n"; 
  } 
  else {
      echo "Upload failed"; 
  }
  
  echo "&lt;/p&gt;"; 
  echo '&lt;pre&gt;'; 
  echo 'Here is some more debugging info:'; 
  print_r($_FILES); print "&lt;/pre&gt;";
  </code></pre>
  
  <p>form page:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="upload.php" method="POST"&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="10000000" /&gt;
      Send this file: &lt;input name="userfile" type="file" /&gt;
      &lt;input type="submit" value="Send File" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>the <strong>error</strong> output is :</p>
  
  <pre><code>Upload failed
  
  Here is some more debugging info:Array (
      [userfile] =&gt; Array
          (
              [name] =&gt; test.pdf
              [type] =&gt; application/pdf
              [tmp_name] =&gt; /tmp/phptM0p4w
              [error] =&gt; 0
              [size] =&gt; 1287464
          )
  
  )
  </code></pre>
  
  <ul>
  <li>Webserver : NginX</li>
  <li>Permissions for <code>upload.php</code> : 644</li>
  <li>Permissions for <code>upload</code> directory : 755</li>
  <li>Working in SSH with root user.</li>
  <li><strong>Edit :</strong> upload_max_filesize = 2M</li>
  <li><strong>Edit :</strong> post_max_size = 8M</li>
  </ul>
  
  <p>Another thing! After upload is done, I want to get absolute path of the uploaded file. (ex:<code>/usr/share/nginx/www/pitfax/upload/test.pdf</code>)</p>