[HTML]html读取本地文件并显示

<html>
<body>
<script script type="text/javascript">
function show()
{
    var reader = new FileReader();
    reader.onload = function() 
    {
        alert(this.result)
    }
    var f = document.getElementById("filePicker").files[0];
    reader.readAsText(f);
}
</script>
<input type="file" name="file" id="filePicker"/>
<div id = "div1">
</div>
<input type="button" value = "显示"  onclick="show()"/>
</body>
</html>

 

posted @ 2017-11-20 16:06  南水之源  阅读(11761)  评论(0编辑  收藏  举报