score:0
assuming you have already installed multer, if you see the following code
router.post("/", upload.single("myfile"), (req, res, next) => {
console.log(req.file);
the "myfile"
has to be the name of the formfield coressponding to the file that is being passed, which in your case is "imagedata"
. try replacing "myfile"
with "imagedata"
.
also set headers for the axios post request being made from react. the form attributes may not have effect on the manual http requests
var header = {
'content-type': 'multipart/form-data'
}
await axios.post("/", fd,{ headers : header });
try and let me know if it works.
Source: stackoverflow.com
Related Query
- "How to fix Failed to load resource: the server responded with a status of 500 in React and express
- Failed to load resource: the server responded with a status of 431 (Request Header Fields Too Large)
- Amazon S3 - Failed to load resource: the server responded with a status of 403 (Forbidden)
- Failed to load resource: the server responded with a status of 404 (Not Found) in React.js Project deployed
- Failed to load resource: the server responded with a status of 405 (Not Allowed) needs help on nginx.conf
- Failed to load resource: the server responded with a status of 500. Deployed react app with vercel
- Failed to load resource: the server responded with a status of 404 (Not Found) when editing form React Node MySQL
- Faced Failed to load resource: the server responded with a status of 404 () when uploaded my react app to github pages
- IBM-Watson assistant - Failed to load resource: the server responded with a status of 404 (Not Found)
- React app Failed to load resource: the server responded with a status of 404
- how solve this error (Failed to load resource: the server responded with a status of 404 ())
- Failed to load resource: the server responded with a status of 400 () React.js
- SCORM Failed to load resource: the server responded with a status of 404 ()
- React app failed to load resource: the server responded with a status of 404 GraphQL
- Amplify makes `Failed to load resource: the server responded with a status of 400` error
- Deploying a Node.js React App, on CPanel - 'Failed to load resource: the server responded with a status of 404 ()'
- "Failed to load resource: the server responded with a status of 404 (Not Found)" + "Origin … is not allowed by Access-Control-Allow-Origin."
- React-Failed to load resource: the server responded with a status of 400 (Bad Request)
- How to fix the console warning "The resource ... was preloaded using link preload but not used within a few seconds from the window's load event"?
- React proxy, the server responded with a status of 404 (Not Found)
- Reactjs how to call magento 2 api with bearer (the server responded with a status of 401 (unauthorized))
- How to get the actual error from express instead of status 500 in React on failed fetch in POST method?
- How to fix internal server error 500 and refused to load image because of content security policy?
- How to fix the white screen after build with create-react-app?
- How to resolve "Uncaught TypeError: Failed to construct 'Comment': Please use the 'new' operat....." with respect to React JS?
- How to fix Failed to set the 'value' property on 'HTMLInputElement' for react?
- Axios - Uncaught (in promise) Error: Request failed with status code 500
- How to return the user's status within AWS's user pool using Amplify with Javascript?
- How to fix 'The command "npm install" exited with code 1' error when building the ASP.NET Core app with React?
- How do i fix an internal server error when authenticating with Next-Auth
More Query from same tag
- Draft-js get mention position in editorState currentContent
- How to set the 'defaultValue' of 'react-select' multi?
- React-select with formik: changing options passed to select
- Manipulate a string and return it as html
- React truncate text by line
- How can I see state within a function? using hooks
- React-Native ListView renderRow issues passing props. The right way or the wrong way
- map the result to the invert ReactJS
- Using ReactCSSTransitionGroup with styled-component
- ReactJs - How can I add an 'active' class to the nav bar buttons depending on which page is currently being used?
- Value for title can not be cast from ReadablenativeMap to string
- Strategy pattern with React component
- React js: elements returned by map does not render
- How to style Material UI Dialog with Tailwind?
- Deleting session variables after the user logout in reactjs
- Passing useState function as prop to another component
- How to solve the problem with types in NextJs (Typescript)?
- Function changes data of input array
- Error while using searchKitManager in React
- React Number Format adding suffix to the value
- ReactJS inline editing
- How do you await multiple axios calls with pagination in React?
- Trying to map data through props to React Bootstrap Accordion - data not displaying?
- React-Router 1.0.0 Uncaught Error: Invariant Violation: Element type is invalid
- react-select: how to keep dropdown open when styling in inspector?
- How can I convert React Element to Html element?
- make tooltip content delay using react state
- Is there a way to create a <style> object with React?
- Correct TypeScript Type for thunk dispatch?
- useState not behaving as expected