0

Users can add an attachment to the contact on my website but i do not now how to include the attachment in the PHPMailer script, anybody has an idea?

PHPMailer: http://pastebin.com/B2Wj9nur HTML: http://pastebin.com/qwNsxD4r

user1797935
  • 57
  • 1
  • 4
  • There's a couple of explanations: http://stackoverflow.com/questions/11764156/send-file-attachment-from-form-using-phpmailer-and-php – F.E.A Aug 16 '16 at 11:33

1 Answers1

0

Pls have a look, not tested.

$mail = new PHPMailer(true);


if (isset($_FILES['uploaded_file']) &&
    $_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK) {
    $mail->AddAttachment($_FILES['uploaded_file']['tmp_name'],
                         $_FILES['uploaded_file']['name']);
}


$mail->AddAddress('whoto@otherdomain.com', 'John Doe'); 
$mail->SetFrom('name@yourdomain.com', 'First Last'); 
//....
//other email code
$mail->Send();
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130