Axios在POST上将文件作为空对象发送。

问题描述 投票:0回答:1

我正在使用Vue和使用axios发送请求.通过POST方法,我有一个包含许多数据的请求体,除了当我试图发送一个文件时,一切都很好。在chrome开发工具中,我可以看到假设有一个文件(blob对象)的字段变成了一个空对象。我已经尝试了所有的内容头和所有的东西,但它就是不工作。

axios({
    method : 'post',
    url : 'http://localhost:1323/restricted/Profile',
    headers: {
        'Content-Type': `multipart/form-data;`,
    },
    data : {
        name: this.name,
        pass: this.pass,
        email: this.email,
        fullname : this.fullname,
        isadmin : this.isAdmin,
        bdate : new Date(this.birthDate),
        startworkday : new Date(this.workDate),
        gender : this.gender,
        address : this.address,
        hometown : this.hometown,
        gradschool : this.gradschool,
        phonenum : this.phonenum,
        cv : this.cv,
        nominator : this.nominator,
        salary : this.salary,     
    },
})
.then((respone) => {
    console.log(respone.data);
});
javascript axios
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.