我正在尝试从FileList对象中过滤或删除一些文件。我已经从目录选择器中获取了一个FileList对象。
<input type="file" accept="image/*" webkitdirectory directory multiple>
在我的.ts文件中:
public fileChangeListener($event: any) {
let selectedFiles=$event.target.files; //Object of Filelist
}
selectedFileList 包含不同类型的文件,如 image/jpg、image/png、application/javascript、application/pdf 等。我想要只获取图像类型文件的 FileList 对象。我该如何做到?
注意:HTML 输入元素中的 accept="image/*" 在这里不起作用。
{
lastModified:1521624250148,
lastModifiedDate:Wed Mar 21 2018 15:24:10 GMT+0600 (+06) {},
name:"rxlnn70l.bmp",
size:814138,
type:"image/bmp",
webkitRelativePath:"second/rxlnn70l.bmp",
}
在我的代码中出现了错误:error: files.slice 不是一个函数
File
对象的数组。 - T.J. Crowder