Today, when the front-end uses Vue to transfer files with formdata, the background node reports an error
Multipart: Boundary not found multer
It is found in the front console that the file file transmitted by the interface is null {}, because it is set when Axios requests
the Header of Content-Type is multipart/form-data
It is found that there is no boundary parameter later, except multipart/form data
multipart/form-data;boundary :****************
There should also be a series of boundary parameters. First of all, do not splice the contents behind the boundary, otherwise you need to reconfigure all the content parameters yourself.
later, it is found that it is the reason for the request method, and you need to use ajax to make the request.
the solution is as follows
// upload the files
export function reqUploadImg(file, user_id) {
return axios({
url: '/uploadImg',
method: 'POST',
Headers: {
"content-type": "multipart/form-data",
},
data: file,
params: { user_id }
})
}
This problem can be solved. It will automatically splice a string later, or “content type”: “multipart/form-data” in “multipart/form-data” will also be spliced automatically if it is set to fasle, but after personal experiments, it is found that the types have changed into JSON format, which is automatically generated by Axios source code
Read More:
- Node Error: Error: Multipart: Boundary not found [How to Solve]
- [Solved] This dependency was not found: * core-js/modules/es.error.cause.js in ./node_modules/_@babel_runtim
- [Solved] webpack Package Error: ERROR in multi ./src/main.js ./dist/bundle.js Module not found: Error: Can‘t resolv
- Solution to some map files in JS folder after Vue packaging (remove the map. JS file)
- [Solved] node.js request Error: Error: unable to verify the first certificate
- [Solved] Node.js: Error: connect ECONNREFUSED ::1:3306
- Module not found: Error: Can‘t resolve ‘core-js/modules/es.promise.js‘ in
- React error boundary (What You Should Know & How to Solve)
- How to Solve Files Upload Error: http://net::ERR_SSL_PROTOCOL_ERROR
- Node.js Error: Cannot find module express [How to Solve]
- [Weex]Error in creating project NPM: unable to load file D:\program files\nodejs\node_ global\ weex.ps1 Because scripts are not allowed to run on this system.
- Using ts-node to Execute .ts files Error [Solved]
- node.js yarn Error: SyntaxError: Unexpected string [How to Solve]
- [Solved] Nuxt Import qrcodejs2.js / QRCode.js Error: document is not defined
- [Solved] Node.js v17 npm run dev Error: opensslErrorStack
- [Solved] NPM node ERROR in main..js from Terser ChildProcessWorker.initialize Excaption
- Node.js Error: “Error: EBUSY: resource busy or locked, stat“
- Node.js Error: Error: Cannot find module ‘express‘ [How to Solve]
- Error notarget No matching version found for [email protected]. [How to Solve]
- [Solved] Error: ENOENT: no such file or directory, scandir ‘..\node_modules\node-sass\vendor‘