您好我的html和php代码下面有一个工作表单。 php代码是email.php,但我需要你的帮助这个如何我在我的电子邮件表单上添加附件文件表单已经工作没有文件附件我怎么能将它添加到email.php所以文件附件将与其他字段一起发送看看“class =”自定义文件输入“这是文件附件的输入字段谢谢
HTML表格
<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表格
<?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();
?>