Hi i have a working form below with my html and php code. the php code is the email.php but i need your help with this one How can i add the attachment file on my email form the form is already working without the file attachment how can i add it to the email.php so the file attachment will send along with the other fields take a look with the " class="custom-file-input" thats the input field for file attachment thanks
HTML FORM
<form id="aform" method="POST" action="<?php bloginfo('stylesheet_directory'); ?>/email.php" class='ajaxform'>
<div class="form-group">
<input type="name" class="form-control" name="first_name" id="name" placeholder="Name">
</div>
<div class="form-group">
<input type="numberorcontact" name="phone" class="form-control" id="numberorcontact" placeholder="Email">
</div>
<div class="form-group">
<textarea class="form-control" name="message" placeholder="Message:"id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="custom-file-input" class="file" type="file" name="fileToUpload" id="fileToUpload">
</div>
<button type="submit" name="submit" class="btn btn-default submit">SUBMIT</button>
</form>
PHP FORM
<?php
ob_start();
$EmailFrom = "email.com";
$EmailTo = "email.com";
$Subject = "Contact form";
$first_name = Trim(stripslashes($_POST['first_name']));
$phone = Trim(stripslashes($_POST['phone']));
$message = Trim(stripslashes($_POST['message']));
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
$Body = "";
$Body .= "name: ";
$Body .= $first_name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");
if ($success){
header('Location: http://goldenjoyfranchising.com/');
}
ob_end_flush();
?>