AjaxFileUpload have more options than "file",

Can I have more options to send to url: using ajaxFileUpload?

I use $ .ajaxFileUpload (), and when I ajax fileupload, I also want to pass an additional parameter. Im only passes a parameter called "file", with the file you upload to it. The settings are as follows:

url:'photo.php?mode=upload',
secureuri:false,
type: 'post',
fileElementId:'file',
dataType: 'json',
success: function (data, status)

tried to add data: {param: '1'}, but it doesn't skip anything.

+3
source share
4 answers

data: {'id': id}

Example:

$.ajaxFileUpload
     (
         {
             url: 'SampleReportEditHandler.html',
             secureuri: false,
             fileElementId: 'UploadFile',
             data: { 'id': '100' }
             beforeSend: function () {},
             success: function (data, status) {},
             error: function (data, status, e) {}
         }
     )
+5
source

Could you achieve your goal by adding another GET parameter to the URL?

url:'photo.php?mode=upload&file=someFileName'

I am not completely familiar with this jquery plugin. Are you sure it supports the parameter?

+1
source

. javascript, :

data ={name:'my name', description:'short description'}

ajaxFileUpload

$.ajaxFileUpload
(
  {
    url:url, 
    data: data,
    dataType: 'json',
    secureuri:false,
    fileElementId:'fileElementId'
  }
)

, :

var data = {};
$("#" + formId + " :input").each(function(){data[this.name]=this.value});
+1

I am using the jQuery ajax form plugin , but ajaxFileUpload looks like it works the same. You can set the data type to "json" or "xml" and it should send all the fields in your form to the url.

0
source

Source: https://habr.com/ru/post/1787773/


All Articles