I haven"t written much that ts, is also looking up angularjs while writing. What should I do to select a file at the front end and read it for base64,? My js level is still in the jquery era, please do not hesitate to comment
pseudo code:
import { Component } from "@angular/core";
@IonicPage()
@Component({
selector: "test",
templateUrl: "test.html",
})
export class TestPage {
base64=""; // base64
constructor(
public navCtrl: NavController,
public navParams: NavParams
) {};
readPicFile(){
var file_ipt=document.getElementById("file_up");
var file = file_ipt.files[0];
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
base64 = this.result; //
// base64
}
}
}