I have a form on example.com/contact-us.php that looks like this (simplified):
<form method="post" action="process.php" enctype="multipart/form-data"> <input type="file" name="uploaded_file" id="uploaded_file" /> <input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> </form>
In my process.php file, I have the following code using PHPMailer() to send email:
require("phpmailer.php"); $mail = new PHPMailer(); $mail->From = me@example.com; $mail->FromName = My name; $mail->AddAddress(me@example.com,"John Doe"); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = "Contact Form Submitted"; $mail->Body = "This is the body of the message.";
Email sends the body correctly, but without the attachment uploaded_file .
MY QUESTION
I need an uploaded_file from a form to attach to an email and submit. I don't care about saving the file after the process.php script sends it by email.
I understand that I need to add AddAttachment(); somewhere (I assume in the Body line) for the attachment to be sent. But...
- What do I put at the top of the
process.php file to pull out the uploaded_file ? How is something using $_FILES['uploaded_file'] to pull a file from contact-us.php? - What is included in
AddAttachment(); for the attached file and sent along with the email and where should this code go?
Please help and tell the code! Thank!
php phpmailer file-upload email-attachments
adamdehaven Aug 01 '12 at 17:07 2012-08-01 17:07
source share