vue axios 上传文件时修改Content-Type
// 根据后台需求数据格式const form = new FormData()// 文件对象form.append('upload_file', file) //文件流参数form.append('path', 'news') // 添加form表单中其他数据console.log(form)axios.post(url, form, {headers: {'Content-..
·
// 根据后台需求数据格式
const form = new FormData()
// 文件对象
form.append('upload_file', file) //文件流参数
form.append('path', 'news') // 添加form表单中其他数据
console.log(form)
axios
.post(url, form, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(res => {
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
更多推荐
已为社区贡献1条内容
所有评论(0)