0
這是在WordPress。 我必須提交表單並獲取該文件。 我得到的文本字段中的數據非常好,但無法趕上文件:( 下面有我的代碼。jQuery AJAX提交表單與文件
HTML
<form method="POST" class="JsFormPro" enctype="multipart/form-data">
<table>
<tr>
<td>
<textarea name="WordText" id="WordText" class="WordText" cols="30" rows="10"></textarea>
</td>
</tr>
<tr>
<td>
<input type="file" id="WordFile" class="WordFile" name="WordFile">
</td>
</tr>
<tr>
<td>
<input type="submit" name="" value="Submit">
</td>
</tr>
</table>
</form>
還有就是我的jQuery和AJAX代碼
var form = $('.JsFormPro');
form.on('submit', function(e){
e.preventDefault();
$.ajax({
dataType : 'json',
type: "POST",
url: 'hit.php',
data : {action : 'count_word_prism', Post : form.serialize()},
beforeSend: function(){
},
success: function(Response){
}
});
});
我有PHP代碼,我是嘗試了。
extract($_POST);
if ($Post) {
parse_str($Post, $get_array);
echo"<PRE>";
print_r($get_array['WordText']);
echo"</PRE>";
echo"<PRE>";
print_r($_FILES['WordFile']);
echo"</PRE>";
}
如果有任何解決方法,請發佈您的答案。
嘗試張貼文件,看http://stackoverflow.com/questions/166221/ ?如何燦我上傳 - 文件 - 異步S = 1 | 10.9107 – guest271314