pekebyte/pekeUpload

how to use the data options?

Closed this issue · 5 comments

i have try many fomats..
but my api cannot read the data..

nd3w commented

Yes, a sample will be fine.

well.. i modify some codes in the plugins myself and then my data.options is working :)

nd3w commented

kiro112, if you don't mind, would you share your code?

change this( in pekeUpload.js) :

var formData = new FormData();
formData.append(options.field, obj[0].files[0]);
formData.append('data', options.data);

----------------- to this ----------------
var formData = new FormData();
formData.append(options.field, obj[0].files[0]);

var keys = Object.keys( options.data );
var values = options.data;
for(var i=0; i<Object.keys( options.data ).length; i+=1){
formData.append( keys[i], values[ keys[i] ] );
}

then request data like this
data: { name :'value', status:'Accepted', value2: $('selector').val() }

Thanks Missing this is documention