file64 => {
console.log('file in 64: ', file64);
this returns == data:application/pdf;base64
}).catch(err => {
console.log('booooooo');
});
filepath looks like this == “file:///Users/venkatswamydandaboina/Library/Developer/CoreSimulator/Devices/9A8C76B7-F443-409E-8B62-377E7713DB67/data/Containers/Data/Application/D1AD60AE-D75C-4065-8B44-32470A3DA5DA/Library/NoCloud/”
but it doesnt returns base64 string it only returns “data:application/pdf;base64”.
It would be easier if we have the base64 format. I need it because I want to upload it to my server via REST API along with other parameters in the registration form
I don’t know why this misconception is so persistent and widespread.
Ever since the infancy of the web, the multipart/form-data content type has supported including binary data as part of a request. In modern times, FormData makes for very clean and straightforward code when doing this as an XHR POST, which is probably what you’re doing with it. The WebView will even handle setting Content-Type for you when you do this.
this.fileInputClick.nativeElement.click();
// this will open file chooser
}
// here the event gets triggered after selecting the pdf file
onFileChange(event) {
console.log(event.target.files)
var filename = event.target.files[0].name
console.log("File Name")
console.log(filename)
var fileReader = new FileReader();
fileReader.readAsDataURL(event.target.files[0])
fileReader.onload = () => {
console.log(fileReader.result)
// here this method will return base64 string enjoy