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

195
Views
Save many file in FileList[0]

I have 2 input upload file and same function and file save in array from push

  manyImage = []
  selectImage(event) {
    if (event.target.files.length > 0) {
      this.manyImage.push(event.target.files)
    }
    console.log(this.manyImage)
  }

when i use console.log(this.manyImage)

output:

(2) [FileList, FileList]
0: FileList {0: File, length: 1}
1: FileList {0: File, length: 1}
length: 2

what i need :

when i uploaded 2 times different input file but same function the output will be like this

what i want output:

0: FileList {0: File, 1: File, length: 2}
length: 1

i want save all file in one array and in index of FileList[0] please help

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

0

Try creating an array from the FileList and concating the first FileList array with the next one.

I am not sure if your mayImage array will only have zero or one items. In case it will then you could try this snippet:

if (this.manyImage.length == 0) {
   this.manyImage.push(
      Array.from(event.target.files)
    );
} else {
   this.manyImage[0] = this.manyImage[0].concat(
       Array.from(event.target.files)
   );

If your manyImage array will contain more than one item then you need to specify which item to merge the two FileList in and then you can adjust the code snippet.

about 4 years ago · Juan Pablo Isaza Report

0

You can use ES6 destructing:

selectImage(event) {
   if (event.target.files.length > 0) {
      this.manyImage.push(...event.target.files);
   }
   console.log(this.manyImage)
}
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!