我目前正在开发一个项目,该项目将文件作为 blob 存储在数据库中。我需要将文件附加到电子邮件并通过 PHPMailer 发送出去。我熟悉$mail->addAttachment()
,但是,这个函数似乎只接受文件路径,而我没有。我想知道是否有任何方法可以操纵 blob 并提供给这个函数?
我很感激任何建议,提前致谢!
以下内容成功创建了我需要附加的文件的“另存为”对话框:
header("Content-disposition: attachment; filename={$filename}.{$file_ext}");
header("Content-type: application/octet-stream");
echo $pdf['data'];
exit;
The addStringAttachment http://phpmailer.github.io/PHPMailer/classes/PHPMailer.PHPMailer.PHPMailer.html#method_addStringAttachment方法能够处理这种情况。根据其文档:
* Add a string or binary attachment (non-filesystem).
* This method can be used to attach ascii or binary data,
* such as a BLOB record from a database.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)