Ionic3 file transfer


#1

I am trying to send the captured image to server. I have mamp sever in my system. server is working fine. Ionic app is capturing image fine and when i send it to server it says “File Transfer Error: Could not connect to the server.”

uploadImage(){
const fileTransfer: FileTransferObject = this.transfer.create();
var randamNo = Math.floor(Math.random()*100);
let options: FileUploadOptions = {
fileKey: ‘file’,
fileName: ‘image_’+randamNo+’.jpg’,
chunkedMode: false,
mimeType: “image/jpeg”,
headers: {}
}
fileTransfer.upload(this.base64Image, ‘http://localhost:8888/image.php’, options)
.then((data) => {
console.log(‘success’);
}, (err) => {
console.log(‘upload error’);
});
}