Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
How to get data form Same <form> with many <input type='file' multiple /> elements as separate set for each input field?

I have a with 3 tags as given below;

 <input type="name" class="form-control" id="name" placeholder="Enter name" name="name[]">
 <input type="text" class="form-control" id="phone" placeholder="Enter phone" name="phone[]">
 <input type="file" name="Image[]" id="image"  multiple />

I enter record of 2 persons. I select 2 images for 1st person and 3 images for 2nd person. When I submit form then I receive data as following;

Array
(
    [name] => Array
        (
            [0] => Mr A
            [1] => Mr B
        )

    [phone] => Array
        (
            [0] => 1234567
            [1] => 9876543
        )

    [Image] => Array
        (
            [0] => 1 (1).png
            [1] => 1 (2).png
            [2] => 1 (3).png
            [3] => 1 (4).png
            [4] => 1 (5).png
        )

    [submit] => Submit
)

Problem is, How can I identify which images belongs to which person. I need data as separate set for each person as following

Array
(
    [name] => Array
        (
            [0] => Mr A
            [1] => Mr B
        )

    [phone] => Array
        (
            [0] => 1234567
            [1] => 9876543
        )

    [Image] => Array
        (
            [0] => Array
                        (
                            [0] => 1 (1).png
                            [1] => 1 (2).png
                        )
            [1] => Array
                        (
                            [0] => 1 (3).png
                            [1] => 1 (4).png
                            [2] => 1 (5).png
                        )
        )

    [submit] => Submit
)

Please help in this context

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I have solved my problem myself. We could not send data as separate group unless we change name attribute. I have fixed by changing the name onClick

<input type="file" name="image[1][]" id="" onchange="countFiles()" multiple />

JQuery

function countFiles(){
 var n = $(':input[type=file]').length; //counts input type file tags
 $(event.currentTarget).attr('name', 'image['+n+'][]'); //changes name
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda