Is it possible to update FileList?

后端 未结 2 1123
广开言路
广开言路 2020-11-28 10:20

I have:


Every time the user selects a file(s), I build a list o

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 10:54

    It's like you said

    you can only set the files with a FileList, unfortunately the FileList is not constructable or changeable, but there is a way to get one in a round about way

    /**
     * @params {array} files List of file items
     * @return FileList
     */
    function FileListItems (files) {
      var b = new ClipboardEvent("").clipboardData || new DataTransfer()
      for (var i = 0, len = files.length; i

    doing this will trigger a change event, so you might want to toggle the change event listener on and off

提交回复
热议问题