PHP fail to move file from temp folder to specified folder
<pre><code>&lt;?php
error_reporting(E_ALL);
include "func.php";
connectToDatabase("localhost","root","","test");
$fileName = $_FILES['name'];
$fileSize = $_FILES['size'];
$fileType = $_FILES['type'];
$fileTempName = $_FILES['temp_name'];
$uploaderID = $_SESSION['id'];
$date = date("d/m-Y");
$uploadDir = "avatarStor/";
$filePath = $uploadDir . $fileName;

if(!$fileName){
    echo "Error: value 'fileName' was undefined&lt;br&gt;";
}

$result = move_uploaded_file($fileTempName, $filePath);
if (!$result) {
    echo "Error: File could not be uploadet: ".$fileName;
    exit;
}

if(!get_magic_quotes_gpc()){
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

$result = mysql_query("UPDATE users SET profilepicture='$fileName' WHERE id='$uploaderID'") or die(mysql_error());

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

<p>I am unable to <code>move_uploaded_file();</code> in this uploading script. I went ahead and <code>chmod 777</code> the folder, but nevertheless, it failed. PHP provides no errors when running.
<img src="http://i.stack.imgur.com/ERNM2.png" alt="Result"></p>
