[英]PHP: Get input and send as attachment in phpmailer
I am using PHPMailer https://github.com/Synchro/PHPMailer To send images as attachments in emails. 我正在使用PHPMailer https://github.com/Synchro/PHPMailer将图像作为附件发送到电子邮件中。
But it's not working when I do this: 但是当我这样做时,它不起作用:
$photo = $_GET['photo_send'];
$photo = realpath($photo);
var_dump($photo);
$mail->AddAttachment($photo); // Add attachments
The image path shows in the url: 图片路径显示在网址中:
photo_send=images%2Ffullscreen%2F1.JPG%3Flol%3Dlol
When I put the path directly in the AddAttachment
it works. 当我将路径直接放在AddAttachment
它可以工作。
If anyone can suggest or give advise, i'd really appreciate it! 如果有人可以提出建议或提供建议,我将不胜感激!
I already said in comments, that your path is not OK. 我已经在评论中说过,您的路径不正确。
You said, if you output $photo
right after $_GET
you get images/fullscreen/1.JPG?lol=lol
您说过,如果您在$_GET
之后立即输出$photo
,则会得到images/fullscreen/1.JPG?lol=lol
When you discovered that you need to remove ?lol=lol
, you found the problem. 当发现需要删除?lol=lol
,您发现了问题。
try this 尝试这个
$photo = images/fullscreen/$_GET['photo_send'];
$mail->AddAttachment($photo);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.