I'm using FormData to upload files. I also want to send an array of other data.
When I send just the image, it works fine. When I append some text to the formdata, it works fine. When I try to attach the 'ProIList' array below, everything else works fine but no array is sent
this is my angular.js file code :
this.AddPro = function (file, P) {
var formData = new FormData();
formData.append("file", file);
formData.append("name", P.name);
formData.append("description", P.description);
formData.append("ProItems", P.ProIList); // this is array list
var Response = $http.post("/Product/AddProduct", formData,
{
transformRequest: angular.identity,
headers: { 'Content-Type': undefined }
})
.success(function (res) {
Response = res;
})
.error(function () {
});
return Response;
}
this is my controller method :
[HttpPost]
[Route("AddProduct")]
public string AddProduct(Pro ProItems) // here i m not getting array
{
string Res = "";
ProItems.name = name;
ProItems.description = description;
db.Promotions.Add(ProItems); // and here add product is done now want to add ProductItems table entry so how can do
db.SaveChanges();
return Res;
}
this is my entity Pro :
public class Pro
{
public int id { get; set; }
public int name {get; set;}
public int descripation{ get; set; }
public List<ProductItems> ProItems { get; set; }
}
with my code i m getting all filed on api side like name,description,also image but just not getting list so can you please know any one where is my misteke.