如何从FileList中删除文件 [英] How do I remove a file from the FileList
问题描述
现在我要删除一些文件,但我不知道如何,或者甚至是可能的。
最好我想从FileList中删除它们;我没有用他们但是如果不可能,那么我应该写代码中与FileList交互的检查?这样看起来很麻烦。
如果您只想删除几个选定的文件:你不能。您链接到的文件API工作草案包含一条注释:
HTMLInputElement
界面
[HTML5]具有只读FileList
属性,[...]
[emphasis mine]
阅读一下HTML 5工作草案,我发现了常用输入
元素API 。您可以通过设置输入
的值
属性来删除整个文件列表对象为空字符串,如:
document.getElementById('multifile')。value =;
BTW,文章使用Web应用程序的文件也可能令人感兴趣。
I'm building a drag-and-drop-to-upload web application using HTML5, and I'm dropping the files onto a div and of course fetching the dataTransfer object, which gives me the FileList.
Now I want to remove some of the files, but I don't know how, or if it's even possible.
Preferably I'd like to just delete them from the FileList; I've got no use for them. But if that's not possible, should I instead write in checks in code that interacts with the FileList? That seems cumbersome.
If you want to delete only several of the selected files: you can't. The File API Working Draft you linked to contains a note:
The
HTMLInputElement
interface [HTML5] has a readonlyFileList
attribute, […]
[emphasis mine]
Reading a bit of the HTML 5 Working Draft, I came across the Common input
element APIs. It appears you can delete the entire file list by setting the value
property of the input
object to an empty string, like:
document.getElementById('multifile').value = "";
BTW, the article Using files from web applications might also be of interest.
这篇关于如何从FileList中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!