How do you handle file uploads from React to Express?
Model answer
Send FormData with the file from the browser (do not set the Content-Type header manually), and parse it on the server with multer, with size and type limits. Show upload progress if needed, store the file path or storage key in MongoDB, and serve files from object storage or a protected route.
Learn this topic
useEffect and Fetching Data from Your API: Loading, Errors and Cleanup in the course MERN Stack Full Course: MongoDB, Express, React and Node.js.
Sign in to add your own answer.
More questions
- How does a React app call an Express API?
- How do you set up a Vite proxy for development?
- How do you serve a React build from Express?
- How do you handle authentication state in a MERN frontend?
- How do you handle loading, error and empty states for API data in React?
- How do you build a dashboard with filters and pagination backed by the API?