0

我正在使用来自:https ://github.com/PHPMailer/PHPMailer 的 PHPMail

我希望能够从根路径开始添加附件:

$email->AddAttachment( "../../admin/billing/invoices/5847884.pdf" , basename("../../admin/billing/invoices/5847884.pdf") );

但我不想使用,而是../../希望能够使用/admin/billing...

我试过了,但它没有附加附件

4

1 回答 1

2

As '/admin/folder/234.pdf' probably is not a valid absolute path in the filesystem, PHPMailer cannot find your file.

You have to add the base directory of your webspace:

$email->AddAttachment($_SERVER['DOCUMENT_ROOT'].'/admin/billing/invoices/5847884‌​.pdf'); 

Btw, you can leave out the second argument, PHPMailer will use basename() on your first argument to get the filename.

于 2013-10-10T10:04:55.147 回答