Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileReader的用法 #21

Open
wohaofang opened this issue Jul 31, 2020 · 0 comments
Open

FileReader的用法 #21

wohaofang opened this issue Jul 31, 2020 · 0 comments

Comments

@wohaofang
Copy link
Owner

如何获得上传文件中的具体内容

 <input type='file' accept='text/plain' onchange='openFile(event)'>

<script>
var openFile = function(event) {
    var input = event.target;

    var reader = new FileReader();
    reader.onload = function(){
        var text = reader.result;
        console.log(reader.result);   // 显示内容
    };
    reader.readAsText(input.files[0]);
};
</script>

使用fileReader 的这个新增的用法

可以得到inpt file 中文件的内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant