Неустранимая ошибка: вызов неопределенного метода PHPMailer :: filenameToType ()

У меня есть следующий фрагмент кода PHPMailer. Проблема в том, что файл успешно загружен на сервер, но вложение не отправлено по почте.

Вот HTML:

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

И PHP это

    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('[email protected]');
$mail->Subject = 'Get a Quote';
$mail->MsgHtml($message);
$mail->AddAttachment("upload/$fileName");
$mail->Send();
}
}

Я также проверил с

    $mail->Body = $message;
$mail->AddAttachment("upload/$fileName");

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]