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

178
Views
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
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!