1.需求图示
2.按图索骥
添加 实际上,添加附件就是
<input type="file" id="myFile">
的控件,var fileList = getElementById(myFile).files
就可以得到选择的文件的FileList对象,这个对象是类数组的对象(含义有点像函数参数arguments)。记住这一点很重要。显示 下面的显示文件名的面板根据上传的文件名
name
显示
3.刨根问底
- FileList类数组对象
console.log(fileList)
打印出来的结果显示:
bash
FileList
0:File
lastModified:1446204650848
lastModifiedDate:Fri Oct 30 2015 19:30:50 GMT+0800 (中国标准时间)
name:"CCGIS.png"
size:809542
type:"image/png"
webkitRelativePath:""
__proto__:File
length:1
__proto__:FileList
思考:我们只需要能动态修改fileList即可,第一想法是将它