Convert image into multipart and send to post server with key in ionic3

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 = {
longitude: this.lng,
photo : this.myphoto,
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.

Why you have shared this here? You have to share wishes related to birthday. Just kidding/

oh please tell me where i share this .?

Check out this tutorial

It should explain how to handle uploading multipart data.

but i want this in ionic not angular .

Ionic 3 relies upon Angular.

please tell me this is good solution or not.

I just sat down to start the day.

Josh’s posts are always great. Have you looked at it?

ok thanx i will check this.