php - PHPMailer refuses to send attachment -


i've been trying while head around , have no clue. i'm trying write simple form send email uploaded file (which expanded useful) , isn't working @ all.

the emails coming through appropriate body, no attachments being included. i've tried file upload form, addattachments linking file on server , addattachments pointing image on imgur , none of them work; attachment never comes through. i'm @ end of patience right now, know i'm doing wrong or way without phpmailer?

html form

<form action="xxxx.php" id="upload" method="post" name="upload"> <input id="filetoupload" name="filetoupload" type="file" />  <input type="submit" /> </form> 

php code

require("../../../classes/class.phpmailer.php"); $mail = new phpmailer();  $mail->from     = "xx@xx.co.uk"; $mail->fromname = "uploader"; $mail->addaddress("xx@xx.co.uk");  $mail->subject  = "first phpmailer message"; $mail->body     = "hi! \n\n first e-mail sent through phpmailer."; $mail->wordwrap = 50; $mail->addattachment( $_files['filetoupload']['tmp_name'], $_files['filetoupload']['name'] );  if(!$mail->send()) {   echo 'message not sent.';   echo 'mailer error: ' . $mail->errorinfo; } else {   echo 'message has been sent.'; 

looking @ form don't have enctype="multipart/form-data" set in form tag.

in addition, need file attachment check make sure attached before sending email. example,

if (isset($_files['uploaded_file']) &&     $_files['filetoupload']['error'] == upload_err_ok) {     $mail->addattachment($_files['filetoupload']['tmp_name'],                          $_files['filetoupload']['name']); } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -