js 读取文本文件,日志内容


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>

    <body>
        <input type='file' accept='text/plain' onchange='openFile(event)'><br>
        <div id="output"></div>
    </body>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>




    <script type="text/javascript">
        var openFile = function(event) {
            var input = event.target;
            console.log('input'+input)
            var reader = new FileReader();
            reader.onload = function() {
                if(reader.result) {
                    //显示文件内容
                    $("#output").html(reader.result);
                }
            };
            reader.readAsText(input.files[0]);




}

    </script>






</html>

 

 

 


免责声明!

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



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