let resizedImage = file // file
let formData = new FormData();
let name = `xxxx.jpeg`;
let file = { uri: "file:///" + resizedImage.path.split("file:/").join(""), type: 'image/png', name: escape(resizedImage.name), fileType: 'image/\*' }; //The key here (uri and type and name) cannot be changed,
formData.append("file", file); //the files here are the key needed by the backend
formData.append("token", token); //the files here are the key needed by the backend
formData.append("key", Math.random()+'__'+name); //the files here are the keys needed by the backend
Read More:
- If the request parameter is formdata, use the Ajax operation
- How to Solve React devtools plug-in Error
- React: How to Solve Web3 import error
- React error boundary (What You Should Know & How to Solve)
- How to React page to achieve entry and exit animation
- How to Solve Files Upload Error: http://net::ERR_SSL_PROTOCOL_ERROR
- [Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.
- [Solved] React Error: ReactDOM.render is no longer supported in React 18.
- [Solved] React Invariant Violation: Minified React error #130
- [Solved] React Dependency Error: Invalid tag name “^np.0.2“ of package “react@^np.0.2“: Tags may not have an
- [Solved] React Click the Event to Modify the State Value Error
- [Solved] Failed to load config “react-app“ to extend from.
- Bugly automatically upload script and report zip error: nothing to do! In xcode10
- [Solved] node.js Upload Files Error: Multipart: boundary not found multer
- [Solved] react-quill failed to install error: Could not resolve dependency
- JS native implementation Promise.all
- [Solved] React Startup Error at the First time :SyntaxError: Unexpected token
- runtime-core.esm-bundler.js5c406620 [Vue warn] Unhandled error during execution of native event h
- React Error: history is undefined [How to Solve]
- [Solved] react-router-dom Error: <NavLink>activeClassName