“Angular Get Base64 z pliku” Kod odpowiedzi

plik konwertujący kątowy na base64

handleUpload(event) {
    const file = event.target.files[0];
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => {
        console.log(reader.result);
    };
}
Zany Zebra

Angular Get Base64 z pliku

  convertFile(file: File): Observable<string> {
    const result = new ReplaySubject<string>(1);
    const reader = new FileReader();
    reader.readAsBinaryString(file);
    reader.onload = (event) => result.next(btoa(reader.result.toString()));
    return result;
  }
	
this.convertFile(event.target.files[0]).subscribe(base64 => {
	this.base64Output = base64;
});
/// NOTE ///
// The event.target.files is just the File Object e.g. from a
// <input type="file"> form
// you can also create a file with the following command:
var f = new File([""], "filename");


JBTheOneAndOnly

Odpowiedzi podobne do “Angular Get Base64 z pliku”

Pytania podobne do “Angular Get Base64 z pliku”

Więcej pokrewnych odpowiedzi na “Angular Get Base64 z pliku” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu