I want to know can we create an upload functionality in react which will upload images to the PUBLIC
folder in react or anywhere in local system without an API?
I was looking for solution but I could not find anything. one thing that I did find is- I can store image inside an array and display it but I am guessing that is cleared once I refresh the page. If you have any suggestion on this as well please.
2
Answers
You can use filereader to upload images. Furthermore follow this link
https://blog.logrocket.com/using-filereader-api-preview-images-react/
other than that you can use this code
import axios from ‘axios’;
import React,{Component} from ‘react’;
class App extends Component {
}
export default App;
You don’t need an API if you just want to move one file from your local disk to the react
public
folder. If I’ve understood correctly your question, you just need to do this:fs
is a Node.JS module which allows you to interact with the file system in a Node.js environment.