here please check below code
public takePicture(sourceType, DestinationType) {
var options = {
quality: 100,
sourceType: sourceType,
destinationType: DestinationType,
saveToPhotoAlbum: true,
correctOrientation: true,
mediaType: 2
// allowEdit : true
};
this.camera.getPicture(options).then((imagePath) => {
if (this.platform.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY) {
this.filePath.resolveNativePath(imagePath)
.then(filePath => {
this.lastImage = this.createFileName();
this.tempPath = "data:image/jpeg;base64," + imagePath;
this.selectedImagePath = imagePath;
this.signaturePad.fromDataURL(this.tempPath);
});
} else {
this.lastImage = this.createFileName();
this.tempPath = "data:image/jpeg;base64," + imagePath;
this.selectedImagePath = imagePath;
this.signaturePad.fromDataURL(this.tempPath);
}
}, (err) => {
this.presentToast(err);
});
}
private createFileName() {
var d = new Date(),
n = d.getTime(),
newFileName = n + ".jpg";
return newFileName;
}
The above code will give me the images and and the path in “imagePath” that I am storing in an array and the “tempPath” is for displaying on signature that is working fine now but for uploading the multiple files like in below code how to send that I am not getting
Please check below code;;
public uploadImage() {
let body: string = JSON.stringify({'postData': this.postData}); //here post data is like this this.postData.push({key:this.selectedImagePath},{key:this.selectedImagePath});
// type: 'application/json',
let headers: any = new Headers({ 'Content-Type': 'application/json' }),
options: any = new RequestOptions({ headers: headers }),
url: any = this.uploadUrl;
this.http.post(url, body, options)
.subscribe((data) => {
let message = data["_body"];
message = JSON.parse(message);
if (message.success == true) {
window.localStorage.setItem("id", message.user_id);
window.location.reload();
}
else {
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: message.message,
buttons: ['OK']
});
alert.present();
}
});
}