PHP:在phpmailer中获取输入并作为附件发送


PHP: Get input and send as attachment in phpmailer

我正在使用PHPMailerhttps://github.com/Synchro/PHPMailer将图像作为附件发送到电子邮件中。

但当我这样做时,它不起作用:

$photo = $_GET['photo_send'];
$photo = realpath($photo); 
var_dump($photo);
$mail->AddAttachment($photo);         // Add attachments

图像路径显示在url中:

photo_send=images%2Ffullscreen%2F1.JPG%3Flol%3Dlol

当我把路径直接放在AddAttachment中时,它就起作用了。

如果有人能提出建议,我将不胜感激!

我已经在评论中说过,你的路径不好。

你说,如果你在$_GET之后输出$photo,你就会得到images/fullscreen/1.JPG?lol=lol

当您发现需要删除?lol=lol时,您就发现了问题。

尝试这个

$photo = images/fullscreen/$_GET['photo_send'];
$mail->AddAttachment($photo);