0

I need to import an excel file and store that in the local folder inside the project repo.

Code:

function ImportTemplate() {
    const [selectedFile, setSelectedFile] = useState();
    const [isFilePicked, setIsFilePicked] = useState(false);
    
    const changeHandler = (event) => {
        setSelectedFile(event.target.files[0]);
        setIsFilePicked(true);
};

   return (
        <div style={{ backgroundColor: "red", height: "100vh" }}>
            <input type="file" name="file" onChange={changeHandler} />
        </div>
    );
}

The above allows you to import the excel sheet but not save it locally.

Sai Krishnadas
  • 2,863
  • 9
  • 36
  • 69
  • By "save it locally" do you mean write a file to the client's file system from within the browser's JavaScript code? – David Nov 23 '22 at 13:53
  • Just save the file to the code repo folder. Btw, the code is in my local computer and its not in production nor uploaded. – Sai Krishnadas Nov 23 '22 at 13:55

0 Answers0