Skip to content

Instantly share code, notes, and snippets.

@anisotropy
Created August 16, 2017 06:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anisotropy/81072001fedb1b8a24d7ccd74bce0e91 to your computer and use it in GitHub Desktop.
Save anisotropy/81072001fedb1b8a24d7ccd74bce0e91 to your computer and use it in GitHub Desktop.
자바스크립트(리액트)에서 텍스트 파일 읽기
import React, {Component} from 'react';
class Example extends Component {
handleChange(e){
let file = e.target.files[0];
let fileReader = new FileReader();
fileReader.onload = () => {
console.log(fileReader.result);
};
fileReader.readAsText(file);
}
render(){
return (
<div>
<input type="file" onChange={tihs.handleChange.bind(this)} />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment