Attach a file to PHPMailer

I am currently working on a project that stores files stored in a database in the form of blocks. I need to attach a file to email and send it via PHPMailer. I am familiar with $mail->addAttachment() , however this function seems to only accept a file path that I don’t have. I was wondering if there is a way to manipulate the blob and serve this function?

I appreciate any suggestions, thanks in advance!

The following file successfully creates a Save As dialog box for the file you want to add:

 header("Content-disposition: attachment; filename={$filename}.{$file_ext}"); header("Content-type: application/octet-stream"); echo $pdf['data']; exit; 
+1
php phpmailer blob
source share
1 answer

The addStringAttachment method is capable of handling such a case. According to his document:

 * 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. 
+3
source share

All Articles