Fail to upload image on server via php
<p>So I have this code in php that takes the result of a form:</p>

<pre><code>&lt;?php if(isset($_POST['upload']) &amp;&amp; $_FILES['userfile']['size'] &gt; 0)
{
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];

    $path = $_SERVER['DOCUMENT_ROOT'] . "/uploads/";
    //$path = "uploads/";
    $path = $path . basename( $_FILES['userfile']['name'] );

    is_uploaded_file( $_FILES['userfile']['tmp_name'] ) or error( 'not an HTTP upload' ); 

    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $path ) )
    {
        echo "The file ". basename( $_FILES['userfile']['name'] ) . " has been uploaded, and your information has been added to the directory"; 
    } 
    else
    {
        echo "Sorry, there was a problem uploading your file --&gt;" . $path;
    }


    } ?&gt;
</code></pre>

<p>The problem I have is that the code go through <code>is_uploaded_file</code> but fails when executing <code>move_uploaded_file</code></p>

<p>This code is code that I've find on many php forum and tutorials.</p>

<p>Anyone has any idea why it doesn't upload on my server.</p>

<p>EDIT:</p>

<p>Here's the full .php file with the html code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Montréal Accessible&lt;/title&gt;
    &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"/&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;link rel="stylesheet" type="text/css" href="vendors/bootstrap/css/bootstrap.min.css"/&gt;
    &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"&gt;
    &lt;link rel="stylesheet" type="text/css" href="stylesheets/home.css"/&gt;
    &lt;link rel="stylesheet" type="text/css" href="stylesheets/grid.css"&gt;
    &lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD9wqmeX_YlaRLZYrnNDOkHcXvlXa9cATo&amp;sensor=false"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="scripts/home.js"&gt;&lt;/script&gt;

    &lt;?php if(isset($_POST['upload']) &amp;&amp; $_FILES['userfile']['size'] &gt; 0)
    {
        $fileName = $_FILES['userfile']['name'];
        $tmpName  = $_FILES['userfile']['tmp_name'];
        $fileSize = $_FILES['userfile']['size'];
        $fileType = $_FILES['userfile']['type'];

        $path = $_SERVER['DOCUMENT_ROOT'] . "/uploads/";
        //$path = "uploads/";
        $path = $path . basename( $_FILES['userfile']['name'] );

        is_uploaded_file( $_FILES['userfile']['tmp_name'] ) or error( 'not an HTTP upload' ); 

        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $path ) )
        {
            echo "The file ". basename( $_FILES['userfile']['name'] ) . " has been uploaded, and your information has been added to the directory"; 
        } 
        else
        {
            echo "Sorry, there was a problem uploading your file --&gt;" . $path;
        }

        $myvars = '';
        $ch = curl_init( $url );
        curl_setopt( $ch, CURLOPT_POST, 1);
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt( $ch, CURLOPT_HEADER, 0);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

        $upImgResponse = curl_exec( $ch );*/
    } ?&gt;

    &lt;script type="text/javascript"&gt;
        window.onload = function()
        {
            loginForm = document.forms[0];
            loginForm.onsubmit=function()
            {
                var name = prompt ("Enter your name","")

                if( loginForm[0].value == '' )
                {
                    alert('Please enter a username');
                    return false;
                }
                else 
                {
                    loginForm.action='../Symfony/web/app.php/login/' + name + '/' + ...;
                    return true;
                }
            }
        }
    &lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
    &lt;div id="container"&gt;
        &lt;div id="headerBar"&gt;
            &lt;div id="homeLogoColumn"&gt;
                &lt;div id="homeLogo"&gt;Montréal Accessible&lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="searchBarColumn"&gt;
                &lt;div id="searchBar" class="input-append"&gt;
                  &lt;input id="appendedInputButton" type="text"&gt;
                  &lt;a id="searchButton" class="btn btn-primary" href="#"&gt;&lt;i class="icon-search icon-white"&gt;&lt;/i&gt;&lt;/a&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="anchorsColumn"&gt;
                        &lt;a class="lastAnchor" href="#"&gt;À propos&lt;/a&gt;
                        &lt;a href="#"&gt;Contact&lt;/a&gt;
                        &lt;a href="#"&gt;Aide&lt;/a&gt;
                        &lt;!--&lt;form name="input" action="" method="post"&gt;
                        &lt;a href="#"&gt;Connexion&lt;/a&gt;&lt;input type="submit" value="Connect"&gt;
                        &lt;/form&gt; --&gt;

            &lt;/div&gt;
        &lt;/div&gt;


        &lt;form method="post" enctype="multipart/form-data"&gt;
        &lt;table width="350" border="0" cellpadding="1" cellspacing="1" class="box"&gt;
        &lt;tr&gt;
        &lt;td width="246"&gt;
        &lt;input type="hidden" name="MAX_FILE_SIZE" value="2000000"&gt;
        &lt;input name="userfile" type="file" id="userfile"&gt;
        &lt;/td&gt;
        &lt;td width="80"&gt;&lt;input name="upload" type="submit" class="box" id="upload" value=" Upload "&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;/table&gt;
        &lt;/form&gt;

        &lt;div id="mainContent"&gt;
                &lt;div id="paramsAndResultsColumn"&gt;
                    &lt;div id="paramsAndResultsTabs"&gt;
                      &lt;ul&gt;
                        &lt;li&gt;&lt;a href="#paramsTab"&gt;&lt;span&gt;Critères&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                        &lt;li&gt;&lt;a href="#resultsTab"&gt;&lt;span&gt;Résultats&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                      &lt;div id="paramsTab"&gt;&lt;/div&gt;
                      &lt;div id="resultsTab"&gt;&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div id="mapCanvasColumn"&gt;
                    &lt;div id="mapCanvas"&gt;&lt;/div&gt;
                &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>EDIT 2:</p>

<p>The error being displayed is the "Sorry, there was a problem uploading...." meaning it goes through the else...</p>
