jQuery文件上传不提交额外的参数 [英] jQuery file upload doesn't submit extra parameters

查看:218
本文介绍了jQuery文件上传不提交额外的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用jQuery File Upload控件中提供的formData参数,在提交时将其他数据发送到服务器。 formData的默认实现是调用一个函数来抓取表单中的所有控件并将它们序列化为一个数组(使用jQuery serializeArray()方法)。

I need to use the formData parameter available in the jQuery File Upload control to send additional data to the server on submit. The default implementation for formData is to invoke a function that grabs all controls in the form and serializes them to an array (using the jQuery serializeArray() method).

我有在我的表单中控件,但是当文件上传时,我没有获得任何其他数据。当我通过Fiddler进行检查时,请求中没有任何内容显示正在提交这些表单字段。

I have controls in my form, but when the file is uploaded, I am not getting any additional data. When I inspect via Fiddler, there is nothing in the request that shows these form fields are being submitted.

是否需要执行其他操作才能使这些表单字段提交?

Is there something additional that needs to be done to get these to submit?

顺便说一下,这两个链接讨论了formData ...

Btw, these two links discuss formData...

https://github.com/blueimp/jQuery-File-Upload/wiki/Submit-files-asynchronously
https://github.com/blueimp/jQuery-文件上传/维基/选项
...为此搜索formData的页面。

https://github.com/blueimp/jQuery-File-Upload/wiki/Submit-files-asynchronously https://github.com/blueimp/jQuery-File-Upload/wiki/Options ...for this one search the page for formData.

为了它的价值, multipart 选项设置为true。

For what its worth, the multipart option is set to true.

推荐答案

我还需要额外传递参数和这里是我使用的:

I also needed to pass an extra parameter and here is what i used :

$('#fileupload').fileupload({
    formData: {
                    param1: 'test'
                    ,param2: "value2"
                    ,param3: "yasseshaikh"
              }
});

formData选项可用于以编程方式设置其他表单数据。

The formData option can be used to set additional form data programmatically.

这篇关于jQuery文件上传不提交额外的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆