title: php move_uploaded_file()
body: <p>So I'm testing out the move_uploaded_file() php script from the w3schools website <a href="http://www.w3schools.com/php/php_file_upload.asp" rel="nofollow">http://www.w3schools.com/php/php_file_upload.asp</a>.
  Here is my code.</p>
  
  <pre><code>if ($_FILES["file"]["size"] &lt; 2000000)
  {
      if ($_FILES["file"]["error"] &gt; 0)
          echo "Return Code: " . $_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 "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br /&gt;";
  
          if (file_exists("/var/www/upload/" . $_FILES["file"]["name"]))
          {
            echo $_FILES["file"]["name"] . " already exists. ";
          }
          elseif(move_uploaded_file($_FILES["file"]["tmp_name"], "/var/www/upload/".$fileName))
              echo "Stored in: " . "/var/www/upload/".$fileName;
      }
  }
  else
      echo "Invalid file";
  </code></pre>
  
  <p>The problem is <code>if(move_uploaded_file($_FILES["file"]["tmp_name"],"/var/www/upload/".$fileName))</code> returns false all the time but it seems the file is stored in the <code>tmp</code> folder on the server (for example: <code>/tmp/php8rrKoW</code>). When I check the <code>tmp</code> folder the file is not there. (It's supposed to get deleted after the script finish executing.) I also don't see the <code>/php8rrkoW</code> folder. I'm not sure if it's supposed to be there. I set the permission for both the <code>tmp</code> folder and <code>/var/www/upload/</code> to <code>777</code> using <code>chmod</code>, but I'm not sure if I should set the owner to <code>apache</code>. So I want to know why the file isn't copied over to <code>/var/www/upload</code> and if there is a way to test this.</p>