Using the below, I am able to ADD attachments to email from $_FILES posts however, they are 0kb / null attached.
The name and content type seems to pickup without issues? Wondering if anyone can shine some light to this.
I am sending the form type as so:
enctype="multipart/form-data"
My file input from HTML form is:
HTML
<input type="file" name="file_input_name" id="file_input_name"/>
PHP
if (array_key_exists('file_input_name', $_FILES))
{
$filecontent = $_FILES["file_input_name"]["tmp_name"];
$filename = $_FILES["file_input_name"]["name"];
$filetype = $_FILES['file_input_name']['type'];
$mail->addAttachment($filecontent, $filetype, $filename, 'attachment');
}
I am using the Sendgrid PHP Library v3. All parts works besides the file itself. In the docs of Sendgrid, you must specify:
addAttachment( content, type, file name, composition )
Please change your code as below
as
$_FILES["file_input_name"]["tmp_name"]only returns the temporary file path where as the first argument of the method requires contents of the file.