(1) The pictures are stored in the database
Use the el-upload component to convert the picture into a string in Base64 format and store it in the MySQL database. The field type is longtext.
(2) Error in front-end display picture
Get the picture data from the back end through the post request and assign it to Src. As a result, the picture cannot be displayed and an error: net::ERR_CONNECTION_RESET 431 (Request Header Fields Too Large)
(3) Problem-solving
Add “data:image/jpeg;base64,” before the base64 format string.
this. form. userPhoto=”data:image/jpeg;base64,”+this. form. userPhoto;
Here, image/JPEG is the name of the data type, Base64 is the encoding method, and the data after the comma is the data taken from the database. You can also check the data URL on the Internet.
So the problem is solved.
Read More:
- If the request parameter is formdata, use the Ajax operation
- [Solved] node.js Upload Files Error: Multipart: boundary not found multer
- Node Error: Error: Multipart: Boundary not found [How to Solve]
- [Solved] it only responds to error and does not enter success after AJAX is successfully processed
- [Solved] Vue Element Date plug-in reports an error in form validation
- Difference between contenttype and datatype in Ajax request of jquery
- Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: String contains non ISO-8859-1 code point.
- How to Fix “HTTP 405 method not allowed” Error
- JS: How to Solve split, join, toString Use error
- How to download files by post submission under Ajax
- JS getting ${pageContext.request.contextPath} Get the root path of the project
- Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)
- [Solved] Element form method resetfields() error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading ‘indexOf’)
- [Solved] nodejs Error: request entity too large
- [Solved] Error in mounted hook: “Error: please transfer a valid prop
- Vue Dynamic Display Picture Error 404: Not Found [How to Solve]
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] Invalid prop: type check failed for prop “modelValue“. Expected Number…
- Use of error attribute in element UI (solution of triggering only once)
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0