Ionic3多图像上传

时间:2019-03-12 14:32:13

标签: image rest http post ionic3

我在ionic V3应用程序中工作。 我想使用http.post请求上传多张图片,但是当我发送请求时,服务器会收到除图片数组之外的所有数据。

这是我的代码:

pickimages() {
this.imgPicker.getPictures({
  outputType: 0
}).then((results) => {
  this.slideOneForm.value.image_file_arr = results
  for (var i = 0; i < results.length; i++) {
    console.log('Image URI: ' + results[i]);
    this.images.push(this.getTrustImg(results[i]))
  }
}, (err) => { console.log("errrrrrrrrrrrr") }); 

}

private win: any = window;
getTrustImg(imageSrc) {
let path = this.win.Ionic.WebView.convertFileSrc(imageSrc);
return (path)

}

save() {
this.submitAttempt = true;

let postObj = this.slideOneForm.value
postObj.api_token = this.token
this.slideOneForm.value.image_file_arr = this.images
console.log(this.slideOneForm.value)
 this.propertyManager.addNewProperty(postObj)
   .then(res => {

   }, err => {

   })

}

提供者功能:

addNewProperty(postData) {
return new Promise((resolve, reject) => {
  this.http.post(this.url + "properties", postData)
    .subscribe(data => {
      resolve(data);
    }, err => {
      reject(err);
    });
});

}

非常感谢。

0 个答案:

没有答案