【发布时间】:2015-11-29 23:50:05
【问题描述】:
好吧,我被难住了。 我有一个ajax方法:
function check_empty() {
if (document.getElementById('name').value == "" || document.getElementById('email').value == "" || document.getElementById('msg').value == "") {
alert("Fill All Fields !");
} else {
//alert("Will submit form");
// e.preventDefault();
$('#spinner').show();
$('#quote_form').hide();
$('#submit').hide();
var formData = new FormData();
formData.append("file", $("#resume").val());
$.ajax({
type: 'post',
url: '/contact_post.php',
data: formData,
success: function(html) {
alert('Enquiry Submitted. Thank You!');
},
error: function(xhr, status, error) {
var jsonResponseText = $.parseJSON(xhr.responseText);
var message = '';
alert('could not submit form: ' + jsonResponseText['message']);
},
//Options to tell jQuery not to process data or worry about content-type.
processData: false,
contentType: false
});
}
firefox 下的请求参数说: -----------------------------4894670511610358147552973488 内容处置:表单数据;名称="文件"
测试.pdf --------------------------4894670511610358147552973488--
但实际的文件数据在哪里?我似乎无法“发送文件”,我在另一端有 PHP 来接收它。
【问题讨论】:
标签: javascript ajax html forms file-upload