Hi,
I got new blank template. added cordova camera plugin & file transfer plugin. I just added one button that invokes camera and get the picture and upload it server. simple POC.
I am testing this in IONIC VIEW
Everything is working fine in IOS. but In Android it always go to error block and returns a null object
{code:null,source:null,target:null, http_status:null,body:null,exception:null}. I have been struggling with this for last few days. Please help
Code:
addimage() { // invoked from button
let options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
// popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true
};
this.getPicture(options);
}
getPicture(options) {
this.plt.ready().then((readySource) => {
Camera.getPicture(options).then((fileUrl) => {
this.uploadpic(fileUrl);
})
})// end get pic from Camera
}
uploadpic(fileUrl:any) {
let srvrurl = "http://ihandi.com/imageuploads/upload.php"
const fileTransfer = new Transfer();
let options: any;
options = {
fileKey: “file”,
fileName: fileUrl.substr(fileUrl.lastIndexOf(’/’) + 1),
chunkedMode: false,
mimeType:“image/jpeg”,
params : {‘fileName’: fileUrl.substr(fileUrl.lastIndexOf(’/’) + 1)}
};
fileTransfer.upload(fileUrl, encodeURI(srvrurl), options,true)
.then((result: any) => {
alert(‘inside upload’);
alert(result.response);
alert(result.response.url);
let res = JSON.parse(result.response);
this.prdimage = res.url;
},(err) => {
alert('Inside error');
alert(JSON.stringify(err));
});
}