php move_uploaded_file forcely gives new name
<p>I am trying to upload file using php, code snippt</p>

<pre><code>$upload_path = "/var/upload/" . $_FILES['mfile']['name'];
if(move_uploaded_file($_FILES['mfile']['tmp_name'], $upload_path))
    echo "file uploaded";
else
    echo "upload failed";
</code></pre>

<p>Note: that /var/upload directory exists and has 777 permission.</p>

<p>The code prints "upload failed"</p>

<p>When I check /var/upload directory, there is file f_505bf77bd8a0f_mypdf.pdf. What went wrong?</p>

<p>Added log ( as per requested by loler):</p>

<pre><code>[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 558, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined variable: showdebug in /Volumes/data/htdocs/ebeu/upload.php on line 559, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: accessories in /var/www/my/web/folder/myupload.php on line 21, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: pmaterial in /var/www/my/web/folder/myupload.php on line 27, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 33, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: occupation_bwc in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: occupation_spec in /var/www/my/web/folder/myupload.php on line 75, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined index: babycarrier in /var/www/my/web/folder/myupload.php on line 78, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined variable: accessories_all in /var/www/my/web/folder/myupload.php on line 79, referer: http://localhost/upload/test/upload.php
[Fri Sep 21 10:58:31 2012] [error] [client ::1] PHP Notice:  Undefined variable: pmaterials_all in /var/www/my/web/folder/myupload.php on line 80, referer: http://localhost/upload/test/upload.php
</code></pre>

<p><strong>Added var_dump($_FILES)</strong></p>

<pre><code>array(1) {
  ["mfile"]=&amp;gt;
  array(5) {
    ["name"]=&amp;gt;
    string(23) "mypdf.pdf"
    ["type"]=&amp;gt;
    string(15) "application/pdf"
    ["tmp_name"]=&amp;gt;
    string(26) "/var/tmp/phpUl6k50"
    ["error"]=&amp;gt;
    int(0)
    ["size"]=&amp;gt;
    int(478704)
  }
}
</code></pre>
