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
image did not saved correctly at my server