<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>T</title>
<style type="text/css">
html{height:100%}
body{height:100%;margin:0px;padding:0px}
#container{height:100%}
</style>
</head>
<body>
<button id="openFileBtn" class="btn" onclick="selectAndOpenFile()">加载文件</button>
<input type="file" name="pic" id="f" style="display: none;" onchange="selectFile(this.files)"/>
<script type="text/javascript">
function selectAndOpenFile()
{
var f = document.getElementById('f');
f.click();
}
function selectFile(files)
{
if (!files.length) {
return;
}
var file = files[0];
console.log(files);
curFile = file;
console.log(curFile);
}
</script>
</body>
</html>