I am facing the file transfer error It’s generating after sending file to server
Below is the my upload function
public uploadImage() {
// Destination URL
const url = SITE_URL + ‘/wp-json/pms-media/v1/media/photo’;
// File for Upload
const targetPath = this.pathForImage(this.lastImage);
// File name only
const filename = this.lastImage;
const options = {
fileKey: ‘file’,
fileName: filename,
chunkedMode: false,
mimeType: ‘multipart/form-data’,
params: { fileName: filename, photoType: this.uploadPhotoType, mediaOrAvatar: ‘saveAvatar’ },
};
const fileTransfer: TransferObject = this.transfer.create();
this.loadingControl = this.loadingCtrl.create({
content: 'Uploading...',
});
this.loadingControl.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(result => {
this.loadingControl.dismissAll();
this.presentToast('Image successful uploaded.');
this.bringsHomePageActivityStream();
},err => {
this.loadingControl.dismissAll();
this.presentToast('Error while uploading file.');
});
}