【发布时间】:2019-07-08 13:21:43
【问题描述】:
图片上传到wordpress正在上传空图片
我正在开发一个使用 wordpress API 的移动应用程序。我的应用程序使用 Nativescript-Vue 框架。我需要使用远程 WP-API 将多个图像上传到 wordpress。
var data=[];
const params = new FormData();
//params.append('file', this.value);
this.product.images.forEach(i => {
params.append('file',i.src);
console.log(i.src);
});
const axiosInstance = axios.create({
baseURL: 'https://mah.ttawor.com/wp-json/wp/v2/',
timeout: 5000,
headers: {
Authorization: this.auth_token,
'content_type':'multipart/form-data' ,
'Content-Disposition':`attachment; filename="product.jpg"`
},
});
if(this.product.images.length === 0) return;
axiosInstance.post('media',params)
.then(response => {
//console.log(response)
})
.catch(err => {
console.log(err)
})
}
不幸的是,Word Press 收到一张空白图片。任何解决方案,我都尝试过 nativescript-background-http。这也不起作用,它与 wordpress 的 oauth 有很多问题
【问题讨论】:
标签: wordpress vue.js axios nativescript