0

i am trying to add an attachment through a html form a then sending that attachment through mail but a error is been found like undefined index on a below particular line so please anybody could help me out.

    $mail->addAttachment($_FILES['file']['tmp_name'],$_FILES['file']['name']);    // Optional name
  • undefined index $_FILES is been encountered. – Bobby gotecha Aug 07 '17 at 07:19
  • 1
    Possible duplicate of [Send File Attachment from Form Using phpMailer and PHP](https://stackoverflow.com/questions/11764156/send-file-attachment-from-form-using-phpmailer-and-php) – Milan Chheda Aug 07 '17 at 07:20
  • May be your `form` is missing `enctype="multipart/form-data"` in it. Add it and try again – Mayank Pandeyz Aug 07 '17 at 07:22
  • Trying to upload this file first then add the path in `addAttachment` check the tutorial [here](http://form.guide/email-form/php-email-form-attachment.html) – Narayan Aug 07 '17 at 07:24
  • You're not paying attention to some basic requirements for handling uploads in PHP. [Read the PHP docs](http://php.net/manual/en/features.file-upload.php), and base your code on [the `send_file_upload` example provided with PHPMailer](https://github.com/PHPMailer/PHPMailer/blob/master/examples/send_file_upload.phps). – Synchro Aug 07 '17 at 07:49
  • Possible duplicate of [send attachment from form with phpmailer not working](https://stackoverflow.com/questions/28233901/send-attachment-from-form-with-phpmailer-not-working) – Synchro Aug 07 '17 at 07:54

1 Answers1

0

use enctype="multipart/form-data" in your form which you are submitting