Without a form
I am trying to post multiple files to my server using AJAX.
This is the input file
<input id="images_input" type="file" name="images" multiple="" class="inputFileHidden">
The result I receive after pressing on the submit button is a FileList
, as shown down below.
I stringify
my File
objects and sending my data through a FormData
object under the picture_files
key.
var data = new FormData()
files = document.getElementById('images_input').files
...
Array.from(files).forEach(file => data.append('picture_files', JSON.stringify(file)))
The problem I have on my Server Side after I request the key from the request.form
object is that I get an empty object
images = request.form['picture_files']
print(images) # result is {}
Any hints on how I can safely JSON.stringify
my javascript objects to my server?