致命错误:调用未定义的方法PHPMailer::filenameToType()

致命错误:调用未定义的方法PHPMailer::filenameToType(),php,html,phpmailer,fatal-error,Php,Html,Phpmailer,Fatal Error,我有下面这段PHPMailer代码。问题是,文件已成功上载到服务器,但附件未通过邮件发送 以下是HTML: <div class="image-upload"><label for="file-input"> <p>Upload File</p></label><input id="file-input" name="file" type="file"/> </div> 你应该减少你的例子来消除外部因

我有下面这段PHPMailer代码。问题是,文件已成功上载到服务器,但附件未通过邮件发送

以下是HTML:

<div class="image-upload"><label for="file-input">
     <p>Upload File</p></label><input id="file-input" name="file" type="file"/>
</div>

你应该减少你的例子来消除外部因素。我建议你去拿那本书。我还将检查其中一些调用的返回值。非常感谢,它与最新的PHPMailer一起工作。
    if (isset($_POST['submit'])) {
    if (!isset($_SESSION['mail_send'])) {
        require'PHPMailer/class.phpmailer.php';

//        $mail = new PHPMailer();
        $fileName = '';
        $filePath = '';
        $type = '';
        $name = $_POST['name'];
        $phone = "Phone number : " . $_POST['phone'];
        $email = $_POST['email'];
        $country = "Country : " . $_POST['country'];
        $dropdown = "Services:" . (isset($_POST['options']) ? implode(", ", `enter code here`array_map("htmlspecialchars", $_POST['options'])) : " not selected ") . "<br />"; // Multimple select box

        $allowedExts = array("doc", "docx", "xls", "xlsx", "pdf", "png", "jpg", "jpeg", "gif");
        $temp = explode(".", $_FILES["file"]["name"]);
        $extension = end($temp);
        if ((($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] ==               "application/msword") || ($_FILES["file"]["type"] == "application/excel")
                || ($_FILES["file"]["type"] == "application/vnd.ms-excel") || ($_FILES["file"]["type"] == "application/x-excel") || ($_FILES["file"]["type"] == "application/x-msexcel")
                || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
                || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg")
                || ($_FILES["file"]["type"] == "image/gif")) && in_array($extension, $allowedExts)) {
            if ($_FILES["file"]["error"] > 0) {
                echo "<script>alert('Error: " . $_FILES["file"]["error"] . "')</script>";
            } else {
                $d = 'upload/';
                $de = $d . basename($_FILES['file']['name']);
                move_uploaded_file($_FILES["file"]["tmp_name"], $de);
                $fileName = $_FILES['file']['name'];
            }
        } else {
            echo "<script>alert('Invalid file')</script>";
            exit();
        }
        $detail = "Message : " . $_POST['details'];
        $message = '<html>
                            <head>
                                <meta http-equiv=\"Content-Type: multipart/alternative; boundary=$boundary". "\r\n". />
                                <title>Verify Your Account</title>
                            </head>
                            <body>
                                <div>' . $phone . '</div>
                                <div>' . $country . '</div>
                                <div>' . $dropdown . '</div>
                                <div>' . $detail . '</div>

                            </body>
                    </html>';


        $mail = new PHPMailer();
        $mail->From = $email;
        $mail->FromName = $name;
        $mail->IsHTML(true);
        $mail->AddAddress('mushahid.hussain@app-desk.com');
        $mail->Subject = 'Get a Quote';
        $mail->MsgHtml($message);
        $mail->AddAttachment("upload/$fileName");
        $mail->Send();
    }
}
    $mail->Body = $message;
    $mail->AddAttachment("upload/$fileName");