I have some troubleshoot with uploading files from react to server side, can you please show me how it must be made correctly?
Bellow, I'm trying to explain the idea what I'm trying to do...
Here is the frontend how looks like:
uploadFile(e) {
let file = e.target.files[0];
axios.post("/uploadFileAPI", file);
}
<input type="file" onChange={this.uploadFile()} />
Here is the backend:
router.post("/uploadFileAPI", (req, res) => {
console.log(req.body.file); //Just need to console log fetched files here or it's path maybe
});
I hope you get point, what I'm trying to do. Can you please show me an example how it should be implemented properly? Thank you