jQuery - 使用$ .post接收$ _FILES数组 [英] jQuery - receiving the $_FILES array using $.post
问题描述
ENCTYPE =multipart / form-data
。 : post = $('#myForm')。serialize();
但是,如何获得 $ _ FILES
数组?我需要这个来处理上传的文件。
这可能使用jQuery,如果是这样的话?或者我需要使用特殊的jQuery上传插件?
jquery form是最好的方法,
您可以将其添加到任何常规表单中,
< form method =postaction =URL>
< input type =filename =file>
< input type =textnametext>
< input type =submit>
< / form>
< script type =text / javascript>
$(document).ready(function(){
$(form).ajaxForm();
})
< / script>
可以按照预期工作,但可以使用ajax。
http://malsup.com/jquery/form/#code-samples
I am attempting to submit a form via jQuery. My form contains fields and a file that must be uploaded. It is of type ENCTYPE="multipart/form-data"
.
I can receive all my field values using: post = $('#myForm').serialize();
But how do I receive the $_FILES
array? I need this to process the uploaded file.
Is this possible using jQuery, and if so how? Or do I need to use a special upload plugin for jQuery?
jquery form is the best way to do it, you can add it to any normal form,
<form method="post" action="URL">
<input type="file" name="file">
<input type="text" name"text">
<input type="submit">
</form>
<script type="text/javascript">
$(document).ready(function() {
$(form).ajaxForm();
})
</script>
will work as expected, but with ajax.
http://malsup.com/jquery/form/#code-samples
这篇关于jQuery - 使用$ .post接收$ _FILES数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!