Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda