FileReader 파일 읽기

3440 단어 프런트엔드 H5
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>H5 filetitle>
head>
<body>
<script>
    function readfile(f){
        var reader = new FileReader();
        reader.readAsText(f,'GB2312');// 
        reader.onload = function(){
            var text = reader.result;
            text = text.replace(/[\s+,'[ Mianhuatang.cc']/g, "");
            text = text.replace(/['。']/g, "
"
); text = text.replace(/ \W{24}/g, ""); text = text.replace(/ \W{24}/g, ""); var out = document.getElementById("output"); out.innerHTML = ""; out.appendChild(document.createTextNode(text)); } reader.onerror = function(e){ console.log('Error',e); } }
script> Select the file to display: <input id="h5file" type="file" onchange = "readfile(this.files[0])"> <pre id="output">pre> body> html>

좋은 웹페이지 즐겨찾기