Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
How can I convert a list of objects to FormData

I have a javascript array which looks like this:

var items = [{
   ID: "1"
   count:'1',
   File: (binary file)
   },
   {
   ID: "2"
   count:'2',
   File: (binary file)
   }
]

I want to get the file input in the backend hence I have to use multipart + formData but I couldnt find a way to convert the list into it. May I know how can I achieve this? Thanks in Advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do this

var items = [
    {
        ID: "1",
        count: "1",
        File: "file",
    },
    {
        ID: "2",
        count: "2",
        File: "file",
    },
];

var myFormdata = new FormData();

myFormdata.append("firstId", items[0].ID);
myFormdata.append("secondId", items[1].ID);

//in loop
items.forEach((item, idx)=>{
  myFormdata.append("id_" + idx, item.ID)
})

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!