let files = e.target.files;
localStorage.setItem('files',JSON.stringify(files));
The storage result is: {"0":{}}
How Solved, waiting online...
阿神2017-05-16 13:45:11
e.target.files
is not an array, so it needs to be converted into an array.
Array.from
Each item of data is a File object. If you want to store the file name, you can take the name attribute.
The code is probably like this:
let files = Array.from(e.target.files).map(x => x.name);
localStorage.setItem('files',JSON.stringify(files));
or
let files = [...e.target.files].map(x => x.name);
localStorage.setItem('files',JSON.stringify(files));