web打开本地文件并读取内容


<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>web打开本地文件并读取内容</title>
</head>

<body>
    <div>
        <input type="file" id="input" onchange="handleFilesopen(this.files[0])">
    </div>
    <script>
        function handleFilesopen(filename) {
            var reader = new FileReader();
            reader.onload = function (evt) { // 指定异步读写后触发的函数
                console.log(evt.target.result);
            };
            reader.readAsText(filename, "gb2312");
        }
    </script>
</body>

</html>

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM