Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular convert file to base64

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

angular get base64 from file

  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");


Comment

PREVIOUS NEXT
Code Example
Typescript :: react typescript stoppropagation 
Typescript :: check schema exists postgresql 
Typescript :: for each typescript 
Typescript :: write in file in typescript 
Typescript :: nestjs ratelimit 
Typescript :: typescript type for jsx element 
Typescript :: for of loop in ts with index 
Typescript :: Missing file extension "tsx" for "./App"(import/extensions) 
Typescript :: angular get item from localstorage 
Typescript :: react native ios safe area padding not working 
Typescript :: create jwt token typescript 
Typescript :: Total elements in a dataframe pandas 
Typescript :: python loop two 
Typescript :: how to generate controllers in nest js 
Typescript :: definition of power in physics 
Typescript :: stored procedure that selects in to a table 
Typescript :: Explain the concept of Dangling Pointer and Null Pointer with Examples? Provide brief details of the scenarios in which pointer acts as dangling pointer. 
Typescript :: parser error cannot read tsconfig.dev.json 
Typescript :: add graphql to strapi 
Typescript :: ggplots in r 
Typescript :: eslint absolute imports error 
Typescript :: c# get amount of elements in enum 
Typescript :: bootstrap dropdown menu not showing 
Typescript :: VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead. 
Typescript :: convert object to list of objects c# 
Typescript :: main concepts in asp.net core 
Typescript :: typescript endless loop 
Typescript :: convert image path to base64 typescript 
Typescript :: convert string to bits c# 
Typescript :: typescript for loop key value pai 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =