我正在尝试设置 PHP Mailer 以允许我从表单发送附件,主要是图像。我有以下代码工作,除了我没有收到附件,它们没有被上传。任何人都可以帮助我或指出我所缺少的正确方向吗?
PHP
<?php
require 'class.phpmailer.php';
date_default_timezone_set('Europe/London');
$mail = new PHPMailer;
$current=date('l F dS, Y, H:i a');
$mail->From = 'me@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('karina@live.co.uk', 'Karina McG');
$mail->addAddress('me@live.com');
$mail->addReplyTo('noreply@tempur.com');
$mail->addCC('');
$mail->addBCC('');
$mail->addAttachment('/var/tmp/file.tar.gz');
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');
$mail->isHTML(true);
$name=$_POST['name'];
$subject=$_POST['subject'];
$system=$_POST['system'];
$country=$_POST['country'];
$description=$_POST['description'];
$mail->Subject = "TEMPUR Web Support Request - $system";
$mail->Body = "Dear $name,<br>
<br>
We have received your TEMPUR request form! - $current<br>
<br>
We will be in contact shortly regarding your issue/s.<br>
<br>
Name : $name <br>
Country : $country <br>
Subject : $subject <br>
System : $system <br>
Description : $description";
$mail->AltBody = 'Hehehe';
//$to="$email";//Will change to Digital Users email!
//Send email
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
?>
HTML
Upload File:<input type="file" name="upload" id="upload"><br>