import React, { useState } from "react";
import "./App.css";
function App() {
const [files, setFiles] = useState("");
const handleChange = (e) => {
const fileReader = new FileReader();
fileReader.readAsText(e.target.files[0], "UTF-8");
fileReader.onload = (e) => {
console.log("e.target.result", e.target.result);
setFiles(e.target.result);
};
};
return (
<div className="App">
<input type="file" onChange={handleChange} />
</div>
);
}
export default App;
결론은 FileReader()가 필요!!
경로 문제때문에!!!