<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" dir="ltr">
<head>
</head>
<body>
<input type="file" id="file" > <!-- 只能上传单个文件 -->
<input type="file" id="files" multiple> <!-- 可以上传多个文件 -->
<script>
window.οnlοad=function(){
var f = document.getElementById("file");
var fs = document.getElementById("files");
//this.files即获取input中上传的file对象 是个数组
f.onchange = function(){
var file = this.files[0];
//获取最后一次修改时间
var date = file.lastModifiedDate;
var year = date.getFullYear();
var month = date.getMonth()+1;
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var second = date.getSeconds();
console.log( year+'-'+month+'-'+day+' '+hours+':'+minutes+':'+second );
//获取文件名称
var fileName = file.name;
console.log(fileName);
//获取文件大小(字节Byte)
var fileSize= file.size;
console.log(fileSize);
var path = file.webkitRelativePath;
console.log(path);
}
fs.onchange = function(){
}
}
</script>
</body>
</html>