I am using formdata for file upload operations...
How do I load the data in array format (one of the properties type is file).
JSON.stringify didn't work
How I use it on the controller side
public class SampleData
{
public string t { get; set; }
public HttpPostedFileBase u { get; set; }
public SampleData() { }
}
public JsonResult Save(FormCollection model, SampleData[] upls) {
...
}
sample data
var data = [{t:"lorem",u: file}, {t:"ipsum",u: file}, { t:"generator", u: file}];
I tried to formdata append in 3 different structures below, but i didn't succeed
My source for the third example
$.each(data, function(index,vs) {
formdata.append('upls[]', vs); // Sample 1
})
$.each(data, function(index,vs) {
formdata.append('upls[][t]', vs.t); // Sample 2
formdata.append('upls[][u]', vs.u);
});
$.each(data, function(index,vs) {
var f = new Array(); // Sample 3
f.t = vs.t;
f.u = vs.u;
formdata.append('upls[]', f);
});