How to get original array of files send from form-data calling via AJAX?

I am using Symfony 4, I’ve created a front page that allows the user to add multiple people before submitting.

Users can click (+) button to add one person.

On these forms, I have some fields to upload documents (its file uploaded) and they can be null if users don’t want to upload.

When the user submits, I created an AJAX calling to my endpoint.
In my controller, I tried to get all files sent by formData in Jquery, but I can not get the array as what I’ve seen from console.log.

My expected is when I get the array of files on PHP code, I want it also contains "undefined" not only FILES.

Datalog before calling AJAX

Datalog before calling AJAX

and

Datalog on PHP (I expected this array should be the same as 1)

Datalog on PHP (I expected this array should be the same as 1

Thank everyone for reading.

Source: Symfony4 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *