无法将文件从tmp_dir移动到server_dir

<?php
$msg = '';
if (array_key_exists('userfile', $_FILES))
    //$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name']));

        $fileName = $_FILES["userfile"]["name"]; 
    $fileTmpLoc = $_FILES["userfile"]["tmp_name"];

        $pathAndName = "uploads/".$fileName;
        $moveResult = move_uploaded_file($fileTmpLoc, $pathAndName);

    if ($moveResult == true) {
        // Upload handled successfully
        // Now create a message
        // This should be somewhere in your include_path
        require_once '/home/jaydeepkanada/public_html/phpMailer/PHPMailer-master/PHPMailerAutoload.php';
        $mail = new PHPMailer;
        $mail->setFrom('accounts@newedgesecurity.in', 'Mail From Website');
        $mail->addAddress('jaydeepkanada@gmail.com', 'Jaydeep Kanada');
        $mail->Subject = 'PHPMailer file sender';
        $mail->msgHTML("My message body");

        $allowedExts = array("doc", "docx", "pdf");
    $extension = end(explode(".", $_FILES["userfile"]["name"]));
        if (in_array($extension, $allowedExts))
        {
            $mail->addAttachment($uploadfile, $_FILES["userfile"]["name"]);
                if (!$mail->send()) {
                    $msg = "Mailer Error: " . $mail->ErrorInfo;
                } else {
                    $msg = "Message sent!";
                }

        }else{
            die("File type not supported. Only PDF or DOC.");
        }  
    } else {
        $msg = 'Failed to move file to ' . $uploadfile;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>PHPMailer Upload</title>
</head>
<body>
<?php if (empty($msg)) { ?>
    <form method="post" enctype="multipart/form-data">
        <input type="hidden" name="MAX_FILE_SIZE" value="100000"> Send this file: <input name="userfile" type="file">
        <input type="submit" value="Send File">
    </form>
<?php } else {
    echo $msg;
} ?>
</body>
</html>

I am using PHP mailer for sending mail with attachments and in this code path is correct but it always showing Failed to move path.

Use the right convertion on file size MAX_FILE_SIZE value, something like 10485760

The problem is the value inside the <input type="hidden" name="MAX_FILE_SIZE" value="100000"> tag being in bytes your uploaded file maybe bigger than 97kbytes (100000 bytes => 97.66 kbytes) so causing the system to give an error (if you look at $_FILES["userfile"]['error'] or $_FILES["userfile"]['error'][0] content, you will see that is giving you error 2 that means "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form".