如何在邮件中附加2个不同的图像

时间:2019-05-27 10:11:15

标签: php phpmailer

if (isset($_FILES['uploaded_file']) && $_FILES['uploaded_file']['error'] ==  UPLOAD_ERR_OK) {
    $mail->AddAttachment($_FILES['uploaded_file']['tmp_name'],
                         $_FILES['uploaded_file']['name']);}

这是用于上传第一张图片的代码,该代码正在起作用,并且在附件中获取附件,但如何为第二张图片添加附件。

1 个答案:

答案 0 :(得分:0)

正如评论中所提到的,您正在使用PHPMailer,因此您可以这样做:

 $mail->AddAttachment($_FILES['uploaded_file']['tmp_name'],
                         $_FILES['uploaded_file']['name']);}

 $mail->AddAttachment($_FILES['uploaded_file2']['tmp_name'],
                         $_FILES['uploaded_file2']['name']);}

您可以遵循以下示例: How to send multiple attachment in single mail in php