Sendgrid PHP / PHPMailer - Attachment not adding to email

37 views Asked by At

I use the below code to GET and upload my file input file to server location. I have no errors however the attachment is not adding to the email upon send?

Here is my code:

HTML

<input type="file" name="fileinput_name" id="fileinput_name"/>

PHP

if (array_key_exists('fileinput_name', $_FILES))
      {

        $uploadfile = move_uploaded_file($_FILES["fileinput_name"]["tmp_name"],"uploadtmp/" . $_FILES["fileinput_name"]["name"]);

        if (move_uploaded_file($_FILES['fileinput_name']['tmp_name'], $uploadfile)) {
           // Attach the uploaded file
            $fileinputname = "uploadtmp/" . $_FILES["fileinput_name"]["name"];
            $mail->addAttachment($uploadfile, $fileinputname);

        }
      }

Mail sends with success and no errors in PHP Log.

Also, would be great if someone has a method to DELETE the file after mailsend OR a way I can achieve this without uploading to server at all?

I have tried these marked Answers however, still not able to attach to mail:

phpMailer Attachment not working

0

There are 0 answers