convert image into multipart and send to post server with key value pair ionic3
// Destination URL
let url = AuthServiceProvider.URLBase+‘json_register.php’;
// File for Upload
var targetPath = this.pathForImage(this.lastImage);;
// File name only
var filename = this.lastImage;
var options = {
latitude: this.lat,
longitude: this.lng,
“securitycodenew”:AuthServiceProvider.SecurityCode,
photo : this.myphoto,
refer_from_email:’’,
fileKey: “file”,
fileName: filename,
chunkedMode: false,
mimeType: “multipart/form-data”,
params : {‘fileName’: filename},
headers: {
‘Content-Type’: undefined,
‘Authorization’: 'Bearer ’ + localStorage.getItem(‘access_token’)
}
};
const fileTransfer: FileTransferObject = this.transfer.create();
// Use the FileTransfer to upload the image
return fileTransfer.upload(targetPath, url, options).then(data => {
return data;
}, (err) => {
return err;
// alert(“Errrr”+ JSON.stringify(err));
});
in this i can’t understand that how to send values in key value pair like securitycode and how to send image in key pair.