I'm attempting to create a form that sends an email with user populated data. So far everything send correctly however the attachment is never included in the email sent. Any help would be appreciated.
HTML form asking user for data. "Mailerindex.html"
<html>
<head>
<link rel ="stylesheet" type = "text/css" href = "style.css" />
</head>
<div class="form-style-8">
<body>
<form action= "PHPMailer.php" method ="POST" id="from"
enctype="multipart/form-data">
<input type="text" name="fname" placeholder="Your Name"/>
<input type="number" name="phoneNum" placeholder="Phone Number"/>
<input type="email" name="email" placeholder="Email Address"/>
<input type="text" name="desc" placeholder="Leave Description"/>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="file" name="file" placeholder="attachment" />
<input type="submit" value="submit" />
</form>
</div>
</body>
</html>
PHP script. "PHPMailer.php"
<?php
require 'PHPMailer-master/PHPMailerAutoload.php';
require 'PHPMailer-master/class.phpmailer.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.xxxxxxxx.edu';
$mail->SMTPAuth = false;
$mail->Username = '';
$mail->Password = '';
$mail->SMTPSecure = 'TLS';
$mail->Port = 25;
$mail->setFrom('xxxxxxxx@gmail.com', 'Mailer');
$mail->addAddress('xxxxxxxxx@vt.edu', 'Joe User');
$mail->isHTML(true);
$fnew =$_POST["fname"];
$phone =$_POST["phoneNum"];
$newEmail =$_POST["email"];
$newDesc =$_POST["desc"];
$file_to_attach = $_FILES['file']['tmp_name'];
$filename=$_FILES['file']['name'];
$mail->AddAttachment( $file_to_attach , $filename );
$message = implode(' ', array($fnew,$phone,$newEmail,$newDesc));
$mail->Subject = 'Auto Email';
$mail->Body = $message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}