I'm concerned about how getFilesAndDirectories() appears to require loading all the File objects in to memory along the way. As it stands it looks like if you just want to examine the file/folder structure, you can't do that without inadvertently loading every File along the way as well, and some might be quite large. So for example if a web app wants to validate that a particular directory structure is valid, it looks like with this proposal it would be unable to avoid possibly significant amounts of file I/O to load File objects that are not yet wanted or needed. Perhaps the browser could return the file tree synchronously (just file names and directory structure), and then a promise-based method would be used to retrieve each File?
Also are there any security implications around users selecting their root system directory? For example if a Windows user selects C:\ as the directory, obviously you may not want to upload that, but now JS has access to their entire system disk structure, right? (Subject to user and app permissions of course, but probably includes all their personal documents)