File data is empty after uploading a PDF with Ionic File Chooser, PDF corrupted

Use base64 Plugin Base64 to convert your File into base64 and send it to server. Pass your FilePath to that plugin and it will convert your file into base64. P.S: I recommend you to upload file as it is don’t Use base64. it will enhance your Applications performance.

import { Base64 } from '@ionic-native/base64/ngx';

constructor(private base64: Base64) { }

...

let filePath: string = 'file:///...';
this.base64.encodeFile(filePath).then((base64File: string) => {
  console.log(base64File);
}, (err) => {
  console.log(err);
});

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top