I have a form with a field that has multi-select enabled. I'm able to get the form data and see the array containing all the files that were selected via the file field.
I'm trying to replace the file array with my selected_files array that I have modified, but when I use FormData.set, it is setting my array as a string it looks like. Please see the below example.
var form = new FormData(document.getElementById("asset-create-form"));
var files = form.getAll('file')
// file field has multiselect enabled so enduser can select more than one file
console.log(files)
>> [File, File, File, File, File] (5)
console.log(selected_files)
>> [File, File, File, File, File] (5)
form.set('file', selected_files)
new_files = form.getAll('file')
console.log(new_files)
>> ["[object File],[object File],[object File],[object File],[object File]"] (1)
Why is this a string? How can I set my selected_files array to the file field?
If the set function can only set to a variable, then is there a workaround?