jQuery file upload doesn't submit extra parameters

耗尽温柔 提交于 2019-12-05 18:19:17

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

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

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

Complete code (I modified the answer provided by Yasser)

Add these code into jquery.fileupload.js

submit: function (e, data) {

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

If the blueimp plugin isn't a requirement I would really recommend the jquery malsup form.

You can use a regular multipart form and just create a regular file input field along with other input fields of your own choice and everything is submitted as usual.

Reference: http://www.malsup.com/jquery/form/

Code sample:

$('#myForm2').submit(function() { 
    $(this).ajaxSubmit(options); 
    return false; 
}); 
user2516513

You have to bind Your data to fileupload. Look at this question
Blueimp jQuery file upload, passing extra form data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!