Hi, I am trying to upload file to server using filechooser for android and filepicker for ios.
For android everything is working fine. but for iOS i am getting error ‘Native: tried calling Filepath.resolveNativePath, but the FilePath plugin is not installed’
but the plugin is actually installed. i have installed 'ionic cordova plugin add cordova-plugin-filepath,
still getting same error.
Here is my code
chooseFileForIos() {
this.filePicker
.pickFile()
.then(uri => {
console.log(uri);
this.toastService.presentToast('File Selected successfully');
this.convertToBase64(uri, true)
})
.catch(err => console.log("Error", err));
}
chooseFileForAndroid() {
this.fileChooser
.open()
.then(uri => {
console.log(uri);
this.toastService.presentToast('File Selected successfully');
this.convertToBase64(uri, true)
})
.catch(e => {
console.log(e);
});
}
convertToBase64(imageUrl, isImage) {
this.filePath
.resolveNativePath(imageUrl)
.then(filePath => {
console.log(filePath);
this.base64.encodeFile(filePath).then(
(base64File: string) => {
console.log("BASE 64 IS", filePath.split(".").pop());
this.postData.ext = filePath.split(".").pop();
this.postData.fileArray = base64File.split(",").pop();
if (isImage == false) {
this.fileArray.push({
displayFile: filePath.split("/").pop(),
base64File: base64File.split(",").pop()
});
Please tell me how to resolve path in iOS.
1 post - 1 participant