title: phpMailer Attachment not working
body: <p>this is my first post and I hope that I can get some help regarding adding an attachment field in my phpMailer contact form. I have already added an uploader [browse] bar in the html website but I don't know how to link it with the phpmailer. do I have to declare it at the package which is phpmailer.php or do something with it?</p>
  
  <p>I would really appreciate some help. Below is my desperate attempt.</p>
  
  <p>Snippet from the code:</p>
  
  <pre><code>&lt;?
  $body = ob_get_contents();
  
  $to = 'xxx@xxxx.com&gt;';
  $email = $email;
  $subject = $subject;
  $fromaddress = "xxx@xxxx.com";
  $fromname = "Online Contact";
  
  require("phpmailer.php"); //&lt;&lt;this is the original pack
  
  $mail = new PHPMailer();
  
  $mail-&gt;From     = "xxx@xxxx.com";
  $mail-&gt;FromName = "My Name";
  $mail-&gt;AddBCC("xxx@xxxx.com","Name 1");
  $mail-&gt;AddAddress( $email,"Name 2");
  
  $mail-&gt;WordWrap = 50;
  $mail-&gt;IsHTML(true);
  
  $mail-&gt;Subject  =  $subject;
  $mail-&gt;Body     =  $body;
  $mail-&gt;AltBody  =  "This is the text-only body";
  // attachment
  $mail-&gt;AddAttachment('uploadbar', 'new_file.pdf'); // the name of my html uploader is uploadbar, clicking browse to locate a file
  
  if(!$mail-&gt;Send()) {
      $recipient = 'xxx@xxxx.com';
      $subject = 'Contact form failed';
      $content = $body;   
  
    mail($recipient, $subject, $content, "From: xxx@xxxx.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
    exit;
  }
  ?&gt;
  </code></pre>