Possibility to feed a file into `<input type="file">` without user intervention?

I would like to understand the possibility to feed a file into <input type="file"> without user intervention. This is used to fill the forms automatically.

I know that, due to security reasons, it is impossible to access the filesystem. However, what I want to understand is the possibility to feed a file obtained in the framework of https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Working_with_files#Store_files_data_locally_using_the_IndexedDB_file_storage_library

In particular, the user could first upload a file into this database, then the extension uses it to fill the form automatically, so that the user only uploads it once and not necessarily “real-time”.

1 Like

Based on documentation you should be able to set the input files via the files property of the <input> element: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement (scroll to "Properties that apply only to elements of type file")

I am not sure whether this works, since FileList is read only - there is no constructor. Seemingly the correct way is via FormData.append(): https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

EDIT: It seems possible to modify the files: https://stackoverflow.com/a/66466544