TypeError:无法读取属性' split' null(...)

时间:2016-11-14 13:54:55

标签: angular cordova-plugins ionic2

我收到TypeError:无法读取属性' split'使用ionic2角度2中的cordova传输插件将图像上传到服务器时出现null(...)错误。这里是代码。

保存图片路径的图片选择器代码:

ImagePick() {
    let options = {
      destinationType   : Camera.DestinationType.FILE_URI,
      sourceType        : Camera.PictureSourceType.PHOTOLIBRARY,
    };
    Camera.getPicture(options).then((imageData) => {


      this.Image = imageData;

      console.log(this.Image);
    }, (err) => {

      // Handle error
    });
  } 

文件传输选项

 let options = {
          fileKey: "avatar",
          fileName: "image.jpg",
          mimeType: "image/jpeg",
          params: {
            food: this.navParams.get("food"),
            location_id: this.navParams.get("location"),
            address: this.navParams.get("address"),
            instructions: this.navParams.get("instructions"),
            phone: this.myForm.controls.phone.value,
              code: "b08d131e06",
            outlets_attributes: 'outlet'
          },
          headers: {headers: this.user_service.Get_Header()}
        };

        console.log(this.Image);

使用cordova传输插件上传带有其他表单元素的图片

  let fileTransfer = new Transfer();
      if(this.Image!=null && this.Image!=""){
          console.log(this.Image);
            fileTransfer.upload(this.Image, URL, options).
            then((data) => {
              console.log(data);
            }, (err) => {
              console.log(err);
            });
      }

我做错了什么。需要帮助...... 谢谢!

0 个答案:

没有答案