Axios将标头Content-Type设置为multipart / form-data

时间:2018-10-05 16:27:50

标签: javascript api axios

我正在尝试使用Javascript中的Axios库发出发布请求,如下所示:

axios.post('/businesses', fd, 
                {
                    headers: {
                        'content-type': 'multipart/form-data'
                    }
                })
                .then(response => {
                    console.log(response);
                    this.completeButton = 'Completed';

                })
                .catch(error => {
                    console.log(error)
                    this.completeButton = 'Failed';
                })

如果我在服务器端输出全局$ _FILES变量,我什么也没得到。

这是控制台中的响应头。我不知道为什么内容类型没有更改。

enter image description here

0 个答案:

没有答案