Phpmailer Addattachment does not work

Asked

Viewed 148 times

0

good night. I’m trying to make an attachment on Phpmailer as follows:

$arquivo = '../enviados/planilha.xlsx';
$mail->AddAttachment($arquivo);

This way, the attachment does not go along with the email. But when I put the file path straight into the Addattachment() function it works:

$mail->AddAttachment('../enviados/planilha.xlsx');

The name of the spreadsheet always changes, I send the name and its path by post, so I’m playing in a variable. If anyone has any tips I would be grateful.

  • Paste the relevant chunk of the PHP error log, which is easier. The probable cause is path not found. Posting the actual chunk of code increases the chance of solution as well (both the post upload form and the code that receives and makes the Addattachment)

  • Then, no "error" occurs, no message appears, the email sends without the attachment. But when I put the path taking the variable (give an echo, copy and lap) it works perfectly. Path not found was my first test, but copying and pasting the path in the url it accesses, besides the way I described above also work. It just doesn’t work even when the path comes by the variable.

  • Paste the last 30 lines of the bug log, just in case.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.