Reputation: 12538
I am currently working on a project that has files stored in a DB as blobs. I need to attach the file to an e-mail and send it out via PHPMailer. I am familiar with $mail->addAttachment()
, however, this function seems to take in a file path only, which I don't have. I was wondering if there is any way to manipulate the blob and feed to this function ?
I appreciate any suggestions, thanks in advance!
The following successfully creates a 'Save As' dialog of the file I need to attach:
header("Content-disposition: attachment; filename={$filename}.{$file_ext}");
header("Content-type: application/octet-stream");
echo $pdf['data'];
exit;
Upvotes: 3
Views: 2906
Reputation: 37770
The addStringAttachment
method is capable of handling such case. According to its doc:
* 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.
Upvotes: 5