I've been trying for a while now to get my head around this and I have no clue. I'm trying to write a simple form to send an email with an uploaded file (which will eventually be expanded into something actually useful) and it just isn't working at all.
The emails are coming through with the appropriate body, but no attachments are being included. I've tried this with the file upload form, with AddAttachments linking to a file on the server and with AddAttachments pointing to an image on imgur and none of them work; the attachment NEVER comes through. I'm at the end of my patience right now, does anyone know what I'm doing wrong or a way to do this 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 This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
$mail->AddAttachment( $_FILES['fileToUpload']['tmp_name'], $_FILES['fileToUpload']['name'] );
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';