score:0
one solution could be to send the image as a string (base64) to the backend to save the image. try to implement this in your react:
import { usestate } from "react";
import "./styles.css";
export default function app() {
const [img, setimg] = usestate("image string will come here");
const handlechangeimg = (e) => {
console.log(e.target.files[0]);
const reader = new filereader();
reader.readasdataurl(e.target.files[0]);
reader.onloadend = () => {
setimg(reader.result);
};
};
return (
<div classname="app">
<h1>hello codesandbox</h1>
<h2>start editing to see some magic happen!</h2>
<input onchange={handlechangeimg} type="file" name="image" />
<button onclick={()=>setimg("image string will come here")}>reset</button>
<h1>{img}</h1>
</div>
);
}
check the code iin codesandbox here.
related resources:
Source: stackoverflow.com
Related Query
- How Can i send image and text user information in react js
- REACT : How can we Upload Image and Input text using Fetch or Axios in a single click function
- How to send a form input data containing both image and text from React front-end to Express backend using Multer
- How can I find and click a button that has no text using React Testing Library?
- How can I combine a React element and text inside a ternary?
- How to validate the form and send user to another page on successful data filled in form fields in React JS?
- How can I send information from one user to another using Firebase realtime database?
- How can i restrict user from not selecting other file types using input type file with react and typescript?
- How can I combine onBlur and onFocus in my React Component without reselecting the text on every letter I type in?
- How can I show an image in the website of a react application, right after a user uploads it?
- React state update error whenever i open someone's image, and image not redering too. How can I fix this error
- How I can create a simple React component rendered as a <div> which takes a text value and a foreground color as input
- How can I add some text on a background image with Material UI Card and CardMedia
- How can I Send data to another Component without using Parent and Child Relation in React
- How can I send image from client to server node js react
- React - How can I get the values from my multiple input and send them to my input?
- how to map in jsx a json string that has image and text information
- How can I define a background image to fill the screen and remove edges on the left and right in React with Material UI?
- How can get both text and value of lookup column on React material-table?
- How can I update State in React using the React-Select Component and User Selection?
- Firebase and React Auth how to update user information
- How can I send Firebase User Email to MongoDB using React Hook Forms?
- How to send user data and its profile image using POST request from axios api to Django Rest Framework?
- How to create a form with text and file input in react and send form data to server using Nodejs?
- How I can add Input text and show in li that created by map in react
- How can I add a user input with an output and be able to display using React Javascript/ Material UI
- How can I send the user saved in passport from the backend server to the React frontend server?
- how to restrict text typing and extra text adding but not italic bold highlighting so that user cannot add text but that can bold text
- How to display the last page when user clicks on add new row,so that user can view the newly added row using react js and prime react
- How can i solve this i am able to send msg and receive but it is not one to one messaging socket io react
More Query from same tag
- React router animations. How to preserve components from unmounting during route transition
- Filter empty arrays from object of arrays in JS
- How get a value in a select before select one?
- How to setup react routing for detail and create page?
- Type 'string' is not assignable to type 'never' and Type 'unknown' is not assignable to type 'never' error in react typescript
- Use react hook inside a axios config file
- Unable to access nested object in React
- Conditional statements not rendering else block
- Add a border to a div in onClick time in react-js
- Losing props state data when reloading the page
- The react component renders several times when using useEffect
- How to prevent a component's state from "propagating" on to the next component in a slideshow
- Update TradingView Hotlist Widget onChange
- Uncaught TypeError: Cannot read property 'call' of undefined at __webpack_require__
- isomorphic-style-loader doesn't work as it supposed to
- How can I maintain my store's state while using react-router and redux?
- React JS - how do I loose focus on an element that was just clicked on?
- how to pull 1 button to the left and 2 button to the right in react>
- Deck.GL ScatterplotLayer does not render circle radius
- Globally mock a function in Jest/Enzyme in React
- REACT JS How can I convert that to as a component?
- Porting a full blown react web app to react native
- Flux + React: when to keep state of visual components at store
- Unit testing ES7 React components with Jest
- ReactJS + Flux: How to pass data attribute from HTML?
- How to get the value of user input field using ReactJS?
- Using AnimateCSS in ReactJs component
- Attach current range number directly above HTML range slider thumb
- align a simple list ,stays round
- Using feather icons with variables in ReactJs