Javascript create a list of objects from a list of files

I have a list of file objects, for example:

var files = [File, File, File]

I want to convert it to something like:

I have a file field in which I want to display the object filesas FileList.

var uploading_files = {}
files.forEach(function(file, key) {
    uploading_files[key] = file

})
var uploader = document.getElementById('uploader')
uploader.files = uploading_files

console.log(uploader.files)

But it does not give me an object FileList? How to create a list of objecdt files? Thanks in advance.

+4
source share
1 answer

The FileList is a read-only object and does not have an implementation of its constructor.

Visit this page: FileList In MDN

+3
source

Source: https://habr.com/ru/post/1648328/


All Articles