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