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

196
Views
Guardar muchos archivos en FileList[0]

Tengo 2 archivos de carga de entrada y la misma función y archivo guardado en matriz desde push

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

cuando uso console.log(this.manyImage)

producción:

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

lo que necesito :

cuando subí 2 veces un archivo de entrada diferente pero con la misma función, la salida será así

lo que quiero salida:

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

quiero guardar todos los archivos en una matriz y en el índice de FileList[0] por favor ayuda

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

0

Intente crear una matriz a partir de FileList y concatenar la primera matriz de FileList con la siguiente.

No estoy seguro de si su matriz mayImage solo tendrá cero o un elemento. En caso de que así sea, podrías probar este fragmento:

 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) );

Si su matriz manyImage contendrá más de un elemento, entonces debe especificar en qué elemento fusionar los dos FileList y luego puede ajustar el fragmento de código.

about 4 years ago · Juan Pablo Isaza Report

0

Puedes usar ES6 destruyendo:

 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!