The pit that axios encountered when uploading file files, no multipart boundary was found

as mentioned in the title, I will describe the problems encountered in detail and post my upload code first

the diamante in the vue component is as follows

     //
        async upLoadFiles(){
          //base64
          this.$refs.cropper.getCropData((data) => {
            const file = this.base64ToFile(data,"");
            let param = new FormData();
            param.append("file",file);
            //FormDataget
            console.log(" param.get:",param.get("file"));
            // console.log(" file:",file);
            this.$apis.UserApi.updateUserIcon(param);
          });
          this.isShowModal = false;
        },

the api,updateUserIcon code is as follows

  updateUserIcon(formData){
    return request({
      url:"user/updateUserIcon",
      method:"post",
      headers:{
        "Content-Type":"multipart/form-data", //
      },
      data:formData,
    }).then( res =>{
      console.log("updateUserIcon :",res);
      return res;
    }).catch( err =>{
      console.log("updateUserInfo :",err);
      return err;
    })
  }

background error message is as follows

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

the output of the browser console is as follows

clipboard.png

clipboard.png

clipboard.png

Jul.19,2022

do not set header, header will be set automatically!

headers:{
    "Content-Type":"multipart/form-data", //
 },

prompt no multipart boundary if you have done something to formData? For example,


this is a problem with my front-end upload format, which has nothing to do with the backend. If you encounter similar problems, you might as well refer to or check whether the information you upload is correct


the same problem is solved online by bloggers. Please tell


because the interceptor of axios
uses axios.crate ()
image.png

image.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e743bb-46287.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e743bb-46287.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?