我不找理由...所以我要求幫助...jQuery的AJAX表格文件
形式:
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php" enctype="multipart/form-data">
<input type="text" placeholder="Name" name="vp" id="contact-form-name" value="" style="color:#9F9F9F; font:13px Arial; float:left; width:180px; border:none; background:none; border:solid 1px #343434;"/>
<textarea name="zinute" rows="3" cols="40" style="color:#9F9F9F; font:13px Arial; float:left; width:180px; border:none; background:none; border:solid 1px #343434;">Text</textarea>
<div style="color:#9F9F9F; font:13px Arial; float:left; width:180px; border:none; background:none;">Photo</div>
<input type="file" required="required" name="foto" style="color:#9F9F9F; font:13px Arial; float:left; width:180px; border:none; background:none; border:solid 1px #343434;">
<input type="submit" class="button" id="contact-form-send" value="Siusti" style="color:#9F9F9F; font:13px Arial; float:left; width:180px; border:none; background:none; border:solid 1px #343434;" />
<script src="jquery.js"></script>
<script src="main.js"></script>
<script src="wow.min.js"></script>
Sendemail
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contact us. As early as possible we will contact you '
);
$vp = @trim(stripslashes($_POST['vp']));
$zinute = @trim(stripslashes($_POST['zinute']));
$foto = @trim(stripslashes($_POST['foto']));
$uploaddir = 'image/';
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
的Jquery:
var form = $('#main-contact-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend(form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn());
}
}).done(function(data){
form_status.html('<p class="text-success">' + data.message + '</p>').delay(3000).fadeOut();
});
});
我只需要工作圖片上傳,不要看任何東西倫敦政治經濟學院,我會但MySQL的,所以只用圖片上傳幫助..
我知道這裏有一個語言不通,但你將需要更清楚的問題。 – David
我的問題是文件上傳與jquery,ajax –
該代碼不發送文件;/ –