Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70903

Ionic 2 Photo upload error with cordova transfer plugin

$
0
0

@UmarRasheed wrote:

TypeError: Cannot read property 'split' of null(…)

i am getting this error while uploading the photo on server using cordova file transfer plugin.

Here is code for image picker

  ImagePick() {
    let options = {
      destinationType   : Camera.DestinationType.FILE_URI,
      sourceType        : Camera.PictureSourceType.PHOTOLIBRARY,
    };
    Camera.getPicture(options).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      this.Image = imageData;
      // this.getFileEntry(imageData);
      console.log(this.Image);
    }, (err) => {
      // Handle error
    });
  }

Here is code for File transfer plugin

 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);
   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);
            });
      }

Need help regarding that issue. Thanks!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70903

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>