# Ionic 5 camera photo corrupted

**URL:** <https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093>\
**Category:** Ionic Angular\
**Created:** [September 29, 2020, 10:34am UTC](https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093 "2020-09-29T10:34:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cmmchado2017](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Cmmchado2017](https://forum.ionicframework.com/u/Cmmchado2017)\
**Post date:** [September 29, 2020, 10:34am UTC](https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093/1 "2020-09-29T10:34:00Z")

</div>

I have this code:  
takePicture() {

```
const options: CameraOptions = {

  quality: 40,

  allowEdit: true,

  correctOrientation: false,

  targetWidth: 200,

  targetHeight: 200,

  destinationType: this.camera.DestinationType.FILE_URI,

  encodingType: this.camera.EncodingType.PNG,

  mediaType: this.camera.MediaType.PICTURE,

  sourceType: this.camera.PictureSourceType.CAMERA    

}

  this.camera.getPicture(options).then(async (imageData) => {

    var thisResult = JSON.parse(imageData);

    this.imageURI_1 = imageData;

    this.imageURI = thisResult.filename;

    console.log(imageData);

    //this.imageFileName = this.webview.convertFileSrc(imageData);

    const tempFilename = this.imageURI.substr( this.imageURI.lastIndexOf('/') + 1);

    const tempBaseFilesystemPath = this.imageURI.substr(0, this.imageURI.lastIndexOf('/') + 1);

            

    this.file.checkDir(cordova.file.dataDirectory, 'fotos/').then(_ => console.log('yay'))

    .catch(err => {

        this.file.createDir(cordova.file.dataDirectory, 'fotos/', false).then(()=>{

        }).catch((err)=>{

        });

    });          

    

    const newBaseFilesystemPath = cordova.file.dataDirectory+'fotos/';

    await this.file.copyFile(tempBaseFilesystemPath, tempFilename, newBaseFilesystemPath, tempFilename);

    

    const storedPhoto = newBaseFilesystemPath + tempFilename;

    //const displayImage = this.webview.convertFileSrc(storedPhoto);

    

    //file:///

    this.imageURI = storedPhoto.substr(7,storedPhoto.length);

    this.imageFileName = this.webview.convertFileSrc(storedPhoto);

    //const resolvedImg = this.webview.convertFileSrc(storedPhoto);

    //this.imageFileName = this.sanitizer.bypassSecurityTrustUrl(this.imageFileName);

      this.ftp.connect('ftp.geacademia.com.br', 'geacademia2', 'Cmm1606799!acad').then(async () => {

          const loading = await this.loadingCtrl.create({

            message: 'Aguarde...',

            duration: 2000

          });

          await loading.present();

            

          let nome_arquivo = '/public_html/alliance/camera/user_'+this.cadcliente.USERAPP.toString()+'.png';

          this.ftp.upload(this.imageURI.toString(), nome_arquivo).subscribe(result => {

              this.ftp.disconnect().then(async () => {

                  const { role, data } = await loading.onDidDismiss();

                  console.log('Loading dismissed!'); 

                  this.presentToast("Imagem Carregada com Sucesso");

                  this.cadcliente.FOTO = 'http://geacademia.com.br/alliance/camera/user_'+this.cadcliente.USERAPP.toString()+'.png';

              }, (err) => {

                  console.log("ERROR: " + JSON.stringify(err));

              });

          }, (err) => {

              this.presentToast(JSON.stringify(err));

          });

      }, (err) => {

          //this.status_proc = "";

          //this.status_proc = "Erro ao Enviar Arquivo...";

      });

  }, (err) => {

      console.log(err);

      this.presentToast(err);

  });

```

}

to take photo at Android works perfectly, but at Iphone, I have this problem!

[user\_Thiago Almeida\_871|200x200](https://forum.ionicframework.com/uploads/short-url/4AzSLRXMo81l6Im4DCJQPxmSEju.png)

image did not saved correctly at my server

---

<div class="post-metadata">

**Author:** ![Cmmchado2017](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Cmmchado2017](https://forum.ionicframework.com/u/Cmmchado2017)\
**Post date:** [September 29, 2020, 11:00am UTC](https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093/2 "2020-09-29T11:00:19Z")

</div>

I´m using an alternative camera plugin camera-cordova-exif

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 29, 2020, 10:37pm UTC](https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093/3 "2020-09-29T22:37:34Z")

</div>

Does the problem persist when using the Capacitor `Camera` instead?

---

<div class="post-metadata">

**Author:** ![Cmmchado2017](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Cmmchado2017](https://forum.ionicframework.com/u/Cmmchado2017)\
**Post date:** [September 30, 2020, 11:01am UTC](https://forum.ionicframework.com/t/ionic-5-camera-photo-corrupted/197093/4 "2020-09-30T11:01:29Z")

</div>

Hi…  
I´m not intend to use Capacitor!!  
Angular is just ok for me!
