首先,我知道有很多与我的问题有关的答案,但实际上并不是我想要的......所以这就是为什么我在这里发帖..
这是我的html表单snippit
<form action="include/jobs.php" id="jobform" name="jobform" method="post" role="form" enctype="multipart/form-data">
<div class="form-process"></div>
<div class="col_half">
<label for="jobform-fname">First Name <small>*</small></label>
<input type="text" id="jobform-fname" name="jobform-fname" value="" class="form-control required" />
</div>
<div class="col_half col_last">
<label for="jobform-lname">Last Name <small>*</small></label>
<input type="text" id="jobform-lname" name="jobform-lname" value="" class="form-control required" />
</div>
<div class="clear"></div>
<div class="col_half">
<label for="jobform-email">Email <small>*</small></label>
<input type="email" id="jobform-email" name="jobform-email" value="" class="required email form-control" />
</div>
<div class="col_half col_last">
<label for="contactform-phone">Phone <small>*</small></label>
<input type="text" id="contactform-phone" name="contactform-phone" value="" class="form-control required" />
</div>
<div class="clear"></div>
<div class="col_full">
<label for="jobform-service">Position <small>*</small></label>
<select name="jobform-position" id="jobform-position" tabindex="9" class="form-control required">
<option value="">-- Select Position --</option>
<option value="Business Executive">Business Executive</option>
<option value="Business Analyst">Business Analyst</option>
<option value="Event Manager">Event Manager</option>
</select>
</div>
<div class="clear"></div>
<div class="col_full">
<label for="jobform-cvfile">Upload CV <small>*</small></label>
<input type="file" id="jobform-cvfile" name="jobform-cvfile[]" value="" multiple class="required form-control file-loading"/>
<div id="errorBlock" class="help-block"></div>
</div>
<div class="clear"></div>
<div class="col_full">
<label for="contactform-message">Message <small>*</small></label>
<textarea class="required form-control" id="contactform-message" name="contactform-message" rows="6" cols="30"></textarea>
</div>
<div class="col_full hidden">
<input type="text" id="jobform-botcheck" name="jobform-botcheck" value="" class="form-control" />
</div>
<div class="col_full">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="6LeCeiYTAAAAACYHIfo4cPO1RoeJkSs_awiB_vVh"></div>
</div>
<div class="col_full">
<button class="button button-rounded button-reveal button-large button-dirtygreen tright" name="jobform-apply" type="submit" value="apply"><i class="icon-line-arrow-right"></i><span>Send Application</span></button>
</div>
</form>
这里是phpmailer脚本
<?php
require_once('phpmailer/PHPMailerAutoload.php');
$toemails = array();
$toemails[] = array(
'email' => 'email@email.com',
'name' => 'company name'
);
$message_success = 'We have <strong>successfully</strong> received your Application and will get Back to you as soon as possible.';
$recaptcha_secret = 'key'; // Your reCaptcha Secret
$mail = new PHPMailer();
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$fname = $_POST['jobform-fname'];
$lname = $_POST['jobform-lname'];
$email = $_POST['jobform-email'];
$position = $_POST['jobform-position'];
$phone = $_POST['contactform-phone'];
$message = $_POST['contactform-message'];
$name = $fname . ' ' . $lname;
$subject = 'New Job Application';
$botcheck = $_POST['jobform-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name'] );
}
$mail->Subject = $subject;
$name = isset($name) ? "Name: $name<br><br>" : '';
$email = isset($email) ? "Email: $email<br><br>" : '';
$phone = isset($phone) ? "Telephone: $age<br><br>" : '';
$position = isset($position) ? "Position: $position<br><br>" : '';
$message = isset($message) ? "Message: $message<br><br>" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name $email $phone $position $message $referrer";
if ( isset( $_FILES['jobform-cvfile'] ) && $_FILES['jobform-cvfile']['error'] == UPLOAD_ERR_OK ) {
$mail->IsHTML(true);
$mail->AddAttachment( $_FILES['jobform-cvfile']['tmp_name'], $_FILES['jobform-cvfile']['name'] );
}
if( isset( $_POST['g-recaptcha-response'] ) ) {
$recaptcha_response = $_POST['g-recaptcha-response'];
$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );
$g_response = json_decode( $response );
if ( $g_response->success !== true ) {
echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
die;
}
}
$mail->MsgHTML( $body );
$sendEmail = $mail->Send();
if( $sendEmail == true ):
echo '{ "alert": "success", "message": "' . $message_success . '" }';
else:
echo '{ "alert": "error", "message": "Email <strong>could not</strong> be sent due to some Unexpected Error. Please Try Again later.<br /><br /><strong>Reason:</strong><br />' . $mail->ErrorInfo . '" }';
endif;
} else {
echo '{ "alert": "error", "message": "Bot <strong>Detected</strong>.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "An <strong>unexpected error</strong> occured. Please Try Again later." }';
}
?>
所以所有字段都工作正常..我可以回复邮件中所有字段的详细信息,但附件不是来找我..
所以我的问题是什么问题?我不是那个进入php ..我知道的东西很少,如果答案很详细就会很棒..谢谢......
还有一个可选问题是有没有办法在phpmailer中指定文件大小限制?