<input id="input" type="file" name="" onchange=changeName(event)>
<span id="span"></span>
function changeName(e){
var span = document.getElementById('span');
span.innerHTML = e.currentTarget.files[0].name;
}
e.currentTarget.files 是一个对象
下面是上传两张图片的情况
-
FileList {0: File, 1: File, length: 2}
-
-
length:2
-
0:File
-
lastModified:1505378490975
-
lastModifiedDate:Thu
Sep 14 2017 16:41:30 GMT+0800 (中国标准时间) {}
-
name:"1
- 副本 (2).png"
-
size:20660
-
type:"image/png"
-
webkitRelativePath:""
-
__proto__:File
-
1:File {name: "1
- 副本 (3).png", lastModified: 1505378490975, lastModifiedDate: Thu
Sep 14 2017 16:41:30 GMT+0800 (中国标准时间), webkitRelativePath: "", size: 20660, …}
-
__proto__:FileList
![]()
文件名 name
类型 type
大小(字节)size
上次修改时间 lastModifiedDate
![]()