获取input上传文件名

来源:互联网 发布:d3.js可视化 编辑:程序博客网 时间:2024/06/05 05:18
<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 是一个对象


下面是上传两张图片的情况


  1. FileList {0File1Filelength2}

    1. length:2
    2. 0:File
      1. lastModified:1505378490975
      2. lastModifiedDate:Thu Sep 14 2017 16:41:30 GMT+0800 (中国标准时间) {}
      3. name:"1 - 副本 (2).png"
      4. size:20660
      5. type:"image/png"
      6. webkitRelativePath:""
      7. __proto__:File
    3. 1:File {name"1 - 副本 (3).png"lastModified1505378490975lastModifiedDateThu Sep 14 2017 16:41:30 GMT+0800 (中国标准时间)webkitRelativePath""size20660, …}
    4. __proto__:FileList



文件名 name

类型 type

大小(字节)size

上次修改时间 lastModifiedDate



阅读全文
1 0
原创粉丝点击