I'm trying to make the file input in the contact form to simply attach the file in the email as an attachment when sent using phpmailer. The code below doesn't show any errors but it just stays on the blank php page and doesn't send the email. Thanks in advance.
<form action="send-mail-tutor.php" method="post" class="form-inline contact-form" entype="multipart/form-data">
<div class="form-group col-sm-10">
<label for="inputName1">Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter first and last name">
</div>
<div class="form-group col-sm-6">
<label for="inputEmail1">Email address</label>
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email">
</div>
<div class="form-group col-sm-6">
<label for="inputPhone1">Phone Number</label>
<input type="tel" class="form-control" name="phone" id="phone-number" placeholder="Enter phone number" maxlength="10">
</div>
<div class="form-group">
<label for="resume">Resume</label>
<input type="file" id="resume" name="resume">
</div> <br/>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<?php
if(isset($_POST['submit'])) {
$emailAddress = "ronniehung95@gmail.com";
// require_once "class.phpmailer.php";
$msg = 'Name: '.$_POST['name'].'<br /> Email: '.$_POST['email'].'<br /> Phone: '.$_POST['phone'];
if (array_key_exists('resume', $_FILES)) {
// first handle the upload
// don't trust provided filename - same goes for MIME types
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['resume']['name']));
if (move_uploaded_file($_FILES['resume']['tmp_name'], $uploadfile)) {
// upload handled successfully
// now create a message
// This should be somewhere in your include_path
require_once 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsMail();
$mail->addReplyTo($_POST['email'], $_POST['name']);
$mail->addAddress($emailAddress);
$mail->setFrom($_POST['email'], $_POST['name']);
$mail->Subject = "New Tutor Applicant";
$mail->msgHTML($msg);
// attach the uploaded file
$mail->addAttachment($uploadfile, 'resume');
$mail->send();
} echo "<script> window.location=../message-sent.php; </script>";
}
}