Axios has the problem of uploading pictures.

because the parameters passed by axios are in json format, and the parameters in formdata format are accepted in the background,
axios.defaults.headers.post ["Content-Type"] =" application/x-www-form-urlencoded;charset=UTF-8";
import qs from "qs";
axios.defaults.transformRequest = [function (data) {
return qs.stringify (data)
}] is globally configured;
converts json data into form-data format with qs.
but I am now in a vue group to upload pictures. The code is as follows:
onRead (file) {

    console.log(file);
    let param = new FormData();
    param.append("file", file.file, file.file.name);
    param.append("userId", this.userInfo.userId);
    param.append("token", this.userInfo.token);
    let config = {
      header: {"Content-Type": "multipart/form-data"}
    }
    let that = this;
    this.$http.post( that.baseUrl + "/user/headPicImg", param, config).then((res) => {
      console.log(res);
      that.imgSrc = "http://116.62.208.141:8181/" + res.data.headImgPath || "../assets/imgs/gift.png";
    })
  },
  form-dataqs
  if(axios.method  === "post" && axios.data.constructor !== FormData){

axios.defaults.transformRequest = [function (data) {

return qs.stringify(data)

}];
}
places restrictions on the conversion conditions, but in this way, some of the interfaces that are not in form-data parameter format are within this judgment condition but are not converted to form-data format by qs. I would like to ask what is wrong with my judgment conditions and how to modify them.

Mar.01,2021

const service = axios.create({
  baseURL: baseUrl,
  // headers: {
  //  'Content-Type': 'application/x-www-form-urlencoded'
  // },
  transformRequest: [function (data) {
    // data['src'] = 'dev'
    if (data instanceof FormData) {
      return data
    }
    data = qs.stringify(data)
    return data
  }]
})
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-1b36c39-4d6da.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-1b36c39-4d6da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?