Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

convert image path to base64 typescript

var xhr = new XMLHttpRequest();       
    xhr.open("GET", "/path/to/local/image/file", true); 
    xhr.responseType = "blob";
    xhr.onload = function (e) {
            console.log(this.response);
            var reader = new FileReader();
            reader.onload = function(event) {
               var res = event.target.result;
               console.log(res)
            }
            var file = this.response;
            reader.readAsDataURL(file)
    };
    xhr.send()
Comment

Converting Image to base64 string in Typescript

function getBase64(event) {
   let me = this;
   let file = event.target.files[0];
   let reader = new FileReader();
   reader.readAsDataURL(file);
   reader.onload = function () {
     //me.modelvalue = reader.result;
     console.log(reader.result);
   };
   reader.onerror = function (error) {
     console.log('Error: ', error);
   };
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: unity get list of all gameobjects with tag 
Typescript :: add comma for input number automatically typescript 
Typescript :: typscript node-ts with nodemon 
Typescript :: typescript checkbox event 
Typescript :: brackets latex 
Typescript :: throw error typescript 
Typescript :: calculate distance between two latitude longitude points in google maps api 
Typescript :: how to declare an empty array in typescript 
Typescript :: warning: failed prop type: the prop `history` is marked as required in `router`, but its value is `undefined`. 
Typescript :: angular 13 component example 
Typescript :: mat-sort not working in dynamically generated table 
Typescript :: add correct host key in /root/.ssh/known_hosts to get rid of this message 
Typescript :: moment datepicker 
Typescript :: multer s3 
Typescript :: typescript type of a function 
Typescript :: extend typescript 
Typescript :: typescript axios 
Typescript :: remove all comments function in c 
Typescript :: from date and to date validation in angular 8 
Typescript :: parameter passing in event emitter 
Typescript :: Text input detect return key react native 
Typescript :: types of variables typescript 
Typescript :: property does not exist on type any typescript 
Typescript :: typescript object get value by key 
Typescript :: serenity.is hide form field 
Typescript :: stop camera if it hits edge of room gml 
Typescript :: merge to datasets in r 
Typescript :: linux copy all directory contents to another directory 
Typescript :: typescript react function coponent props 
Typescript :: requirements check failed for jdk 8 ( 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =