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

179
Vistas
Passing an array of images through input field to server

How can I pass an array variable containing my images in the form of DataURL to my server?

Example of array
["aug.jpg,data:image\/jpeg;base64,\/9j\/4AAQSkZJRgABAQAAAQABAAD\/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDA......]

I have tried to JSON.stringify the value of the array on the front end and attempt to json_decode on the backend but it results in an error :

"error_log() expects parameter 1 to be string, array given"

I have also tried creating a hidden input field for each array of images(dataURL) that I have and serializing the value but when receiving the value of the input on the server, i am unable to convert it back to an array.

for (let k = 0; k < Object.keys(savedImageFilesArray_complex_form).length; k++) {
    console.log("Appending image");
    var img_item = (savedImageFilesArray_complex_form[k]);
    //img_item=JSON.stringify(['testing','testing123']);

    var input = document.createElement("input");
    input.type = "hidden";
    input.name = "finalImageFilesComplexForm"+k+"[]";
    input.class = 'serializeImages' +k;
    input.value = img_item
    appendArea.appendChild(input);

    $('.serializeImages'+k).serialize();
}

(Edited with server code)

Appended below is the value that i am receiving on the $request on the server end. enter image description here

When trying to json_decode the value, it results in the error as mentioned earlier with the parameter 1 being a string rather than an array

  error_log(json_decode($request['finalImageFilesComplexForm0'][0]));
about 4 years ago · Juan Pablo Isaza
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