In frontend, I am using React.
The input
accept the image file
...
onImageChange = event => {
if (event.target.files && event.target.files[0]) {
let img = event.target.files[0]; //This is the image object
//Then convert img to base64
}
};
...
<input type="file" name="myImage" onChange={this.onImageChange} /> //accpet image file
CodeSandbox: https://codesandbox.io/s/gallant-almeida-z6d1x?file=/src/App.js
The image Object will like this
In backend, I am using node.js
Frontend will send api request to backend with the base64 as the parameter,
is it possible to convert it back to image object in backend?