I want to capture picture using camera or choose it from photo library, also want to upload image to my FTP server. I have tested my FTP connection and its working. But I don't know how to upload it to my FTP server.
Please find my code below:
takenPicture:any;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public actionsheetCtrl: ActionSheetController,
public platform: Platform,
public loadingCtrl: LoadingController,
private camera: Camera,
public http:Http,
private ftp: FTP,
public alertCtrl: AlertController
) {
}
resimcek(){
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
saveToPhotoAlbum: false,
allowEdit: true,
targetHeight: 128,
targetWidth: 128
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
this.takenPicture = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
this.ftp.connect('myFTPhost', 'myFTPusername', 'myFTPpassword')
.then((res: any) => console.log('Login Correct'))
.catch((error: any) => console.log('Login Failed'));
this.ftp.upload(this.takenPicture,'myFolder/pictures');
}