None of the answers fully explain this, though they are somewhat correct. The problem is that the 'multiple' attribute must be set AFTER adding the element to the DOM. I'm not sure why it works this way, but I could not get this to work until I changed the order of execution. Here is how it should look:
const fileElement = document.createElement("input");
fileElement.type = 'file';
document.body.appendChild(fileElement);
fileElement.setAttribute('multiple', '');
In my case, I have made this element hidden (with additional code), so I just attached it to the body. You'll want to attach it to a parent element that makes more sense if you are displaying this element.
input.setAttribute('multiple','');