我目前正在一个项目中,该文件具有作为blob存储在数据库中的文件。我需要将文件附加到电子邮件,然后通过PHPMailer发送出去。我很熟悉$mail->addAttachment()
,但是,此功能似乎只采用一个文件路径,而我没有。我想知道是否有任何方法可以操纵Blob并提供给该函数?
我感谢任何建议,在此先感谢!
以下成功创建了我需要附加的文件的“另存为”对话框:
header("Content-disposition: attachment; filename={$filename}.{$file_ext}");
header("Content-type: application/octet-stream");
echo $pdf['data'];
exit;
该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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句