php move_uploaded_file()
<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 if(move_uploaded_file($_FILES["file"]["tmp_name"],"/var/www/upload/".$fileName)) return false all the time but it seems the file is stored in the tmp folder in server (for example: /tmp/php8rrKoW). When I check the tmp folder the file is not there because it's supposed to get deleted after the script finish executing. I also don't see the /php8rrkoW folder, not sure if it's supposed to be there. I set the permission for both the tmp folder and /var/www/upload/ to 777 using chmod. But I'm not sure if I should set the owner to apache. So I want to know why the file isn't copied over to /var/www/upload and if there is a way to test this.</p>
