【问题标题】:Ionic 2 image capture in different folder upload with 1 hitIonic 2 图像捕获在不同的文件夹上传与 1 命中
【发布时间】:2017-09-27 18:34:29
【问题描述】:

我正在创建一个应用程序,我想在不同的文件夹中捕获不同的图像,并且表单中也有一些数据。所以我想在单个 API Hit 中上传所有内容。我面临以下问题: - 1.如何在不同的文件夹中捕捉不同的图像(文件夹是固定的) 2.如何用那个api发送。 我需要的图片如下

我试过了

    pickPicture(){
  Camera.getPicture({
      destinationType: Camera.DestinationType.DATA_URL,
      sourceType     : Camera.PictureSourceType.PHOTOLIBRARY,
      mediaType: Camera.MediaType.PICTURE
  }).then((imageData) => {
    // imageData is a base64 encoded string
      this.base64Image = "data:image/jpeg;base64," + imageData;
  }, (err) => {
      console.log(err);
  });
}

但在这里我无法在不同的文件夹中显示不同的图像。

【问题讨论】:

    标签: angular ionic-framework camera ionic2 cordova-plugins


    【解决方案1】:

    有一个提示。您应该在 pickPicture(){} 上添加任何 id,例如 pickPicture('img1'){}点击按钮,然后传递该 id 以匹配名称并与不同的 id 相同。

    public pickPicture(myurl) {
        //console.log("inside take picture "+myurl);
         Camera.getPicture({({
           destinationType: Camera.DestinationType.DATA_URL,
      sourceType     : Camera.PictureSourceType.PHOTOLIBRARY,
      mediaType: Camera.MediaType.PICTURE
        }).then(imageData => {
          console.log(myurl);
          if(myurl=="Image1"){
            this.Image1 = "data:image/jpeg;base64," + imageData;
          }else if(myurl=="Image2"){
            this.Image2 = "data:image/jpeg;base64," + imageData;
          }});
    

    【讨论】:

      猜你喜欢
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多