php - Sending attachment(s) in email -


I have never touched PHP, but worked to fix an intern's code.

I am trying to upload a file which I am sending. Sends email, but without the file I am using PHPMailerAutoUpload.php (found on GitHub).

I am using this code.

Saving this attachment to move_uploaded_file

  move_uploaded_file ($ resume ['tmp_name'], $ up_dir .basename ($ Random_var. '_wse_'. $ Resume ['name']))   

Note: I have commented the move_uploaded_file function to make sure, I can not get rid of attachment.

  need_once ('phpmailer / PHPMailerAutoload.php'); $ Mail = new PHPMailer (true); $ Mail & gt; IsSMTP (); $ Mail- & gt; SMTPDebug = 2; $ Mail- & gt; SMTPAuth = false; $ Mail- & gt; Host = 'oursmtp'; $ Mail- & gt; Port = 25; $ Mail- & gt; Setfram ($ _POST ['e-mail'], $ _POST ['first_name']. "". $ _POST ['last_name']); $ Mail- & gt; AddAdd ('test@test.com'); $ Mail- & gt; Subject = "test" @date ('m / d / y'); $ Mail & gt; MsgHTML ($ msgDoc); If (isset ($ _ files ['Uploaded file']) & amp; $ _FILES ['Uploaded file'] ['Error'] == UPLOAD_ERR_OK) {$ mail- & gt; AddAttachment ($ _ files ['Uploaded file'] ['tmp_name'], $ _FILES ['uploaded_file'] ['name']); } If (! $ Mail- & gt; Send ()) {$ mailError = $ mail-> Errorinfo; $ OutcomeArr = array ('result' = & gt; 'failure', 'message' = & gt; 'error'. $ MailError); Echo json_encode ($ result bar); Go out(); } And {// success $ resultAre = array ('result' = & gt; 'success', 'message' = & gt; 'thanks'); Echo json_encode ($ result bar); }   

I have read, from, $ _ files is a temporary storage for uploaded files in PHP. With this code, send email, but there are no attachments (only a link to the uploaded file location).

I tried the following, but this is not working for me.

Your internally was apparently a rockstar, to check the status of the error or point it out Was not needed, and would then send the mail even if there was no attachment or if there was an error during upload. To attach the file to you, change these bits in the code:

  if uploaded ('$ 1 $ FILES [' upload_file ']) & amp; $ _FILES ['] File '] [' error '] == UPLOAD_ERR_OK) {if (! $ Mail- & gt; AddAttachment ($ _ files [' Uploaded file '] [' tmp_name '], $ _FILES [' Uploaded file ' ] ['Name'])) {echo 'Error adding attachment:'. $ Mail & gt; ErrorInfo; }} And if (! Isset ($ _ FILES ['upload_file'])) * 'no uploaded file found'; } Else {echo 'Uploaded file error:'. $ _FILES ['uploaded_file'] ['Error']; }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -