Cordova File Plugin giving Security error on using readAsDataUrl

I am using FileChooser to choose a file from my internal storage of my phone and File plugin to convert it into base64 but this.file.readAsDataUrl is giving error “FileError{code:2, Message:SECURITY_ERR}

I have all required permissions still the problem persists below is my code

let base=this
    .then(uri => {

      var array = uri.split("/");

      var path=uri.substring(0, uri.lastIndexOf("/") + 1);

      base.file.readAsDataURL(path, uri).then(dataText=>{
        var data = dataText;


    .catch(e => console.log(e));

I am using Ionic 3, Angular4, Typescript, Firebase

1 Like

Hey. I’m having the exact same issue. Have you been able to find a solution?

If u are uploading files such as pdf/doc/xlsx etc… dont use file plugin , instead use filepath plugin to resolve native uri.

@kkhurana696 Can you provide a example how to use filepath plugin