convert file into base64 in javascript
JavaScript
var fileInput = document.getElementById('#myInputID');
var reader = new FileReader();
reader.readAsDataURL(fileInput.files[0]);
reader.onload = function () {
console.log(reader.result);//base64encoded string
};
reader.onerror = function (error) {
console.log('Error: ', error);
};
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
var file = document.querySelector('#files > input[type="file"]').files[0];
getBase64(file).then(
data => console.log(data)
);
Also in JavaScript:
- Title
- benchmark ram usage angular
- Category
- JavaScript
- Title
- how to find id in array javascript
- Category
- JavaScript
- Title
- how to loop through array of numbers in javascript
- Category
- JavaScript
- Title
- angular local storage
- Category
- JavaScript
- Title
- how to open new tab in vscode using keyboard
- Category
- JavaScript
- Title
- How to get the path to the file that required your module?
- Category
- JavaScript
- Title
- Angular watching for changes in $http.pendingRequests from directive
- Category
- JavaScript
- Title
- ISS proxy express
- Category
- JavaScript
- Title
- Data Change with Mutation
- Category
- JavaScript
- Title
- dropdown list value react fragment
- Category
- JavaScript
- Title
- integers to space separated string in javascript
- Category
- JavaScript
- Title
- addEnd Point js
- Category
- JavaScript
- Title
- Angularjs datetime
- Category
- JavaScript
- Title
- how to set diferent images in html through js
- Category
- JavaScript
- Title
- count occurrences of character in string javascript
- Category
- JavaScript
- Title
- default props react
- Category
- JavaScript
- Title
- create react app deployment heroku
- Category
- JavaScript
- Title
- convert dictionary to json serialization swift 4
- Category
- JavaScript
- Title
- how to make @click in router-link vuejs
- Category
- JavaScript
- Title
- component navigation without changin the url react router
- Category
- JavaScript
- Title
- contact form7 404 wp-json feedback
- Category
- JavaScript
- Title
- convert a string to html element in js
- Category
- JavaScript
- Title
- comment out in javascript
- Category
- JavaScript
- Title
- discord.js multiple embeds
- Category
- JavaScript
- Title
- how to return the max and min of an array in javascript
- Category
- JavaScript
- Title
- javascript access pushed element
- Category
- JavaScript
- Title
- ajax with progress bar
- Category
- JavaScript
- Title
- javascript addeventlistener
- Category
- JavaScript
- Title
- javascript are arrays equal
- Category
- JavaScript
- Title
- class javascript
- Category
- JavaScript
- Title
- how to send an alert in javascript
- Category
- JavaScript
- Title
- functional component react
- Category
- JavaScript
- Title
- javascript Check if an element is a descendant of another
- Category
- JavaScript
- Title
- build filter js
- Category
- JavaScript
- Title
- how to add object to array javascript
- Category
- JavaScript
- Title
- disable right click javascript
- Category
- JavaScript
- Title
- javascript after split then trim whitespace
- Category
- JavaScript
- Title
- Alert.alert closing expo
- Category
- JavaScript
- Title
- how to import a json string from a file in typescript
- Category
- JavaScript
- Title
- history.pushstate
- Category
- JavaScript
- Title
- create new node project
- Category
- JavaScript
- Title
- how to craete a shopping cart in node js
- Category
- JavaScript
- Title
- how to check if 2 sprites are touching js
- Category
- JavaScript
- Title
- express and node
- Category
- JavaScript
- Title
- express route parameters
- Category
- JavaScript
- Title
- boucle for in js
- Category
- JavaScript
- Title
- * http://sizzlejs.com/
- Category
- JavaScript
- Title
- google script get name of google form
- Category
- JavaScript
- Title
- how to split an array in javascript
- Category
- JavaScript
- Title
- .push js
- Category
- JavaScript
- Title
- (not in PATH env variable)
- Category
- JavaScript
- Title
- how to set text for label in jquery
- Category
- JavaScript
- Title
- how to make a vowel counter in javascript
- Category
- JavaScript
- Title
- display none js
- Category
- JavaScript
- Title
- how to create response time router node js
- Category
- JavaScript
- Title
- installing vue router & implementation
- Category
- JavaScript
- Title
- includes()
- Category
- JavaScript
- Title
- compare string by several strings js
- Category
- JavaScript
- Title
- get date one week from now javascript
- Category
- JavaScript
- Title
- how to access array datat in class component react
- Category
- JavaScript
- Title
- change width in js
- Category
- JavaScript
- Title
- arrow function in javascript w3schools
- Category
- JavaScript
- Title
- get day js
- Category
- JavaScript
- Title
- how to make a page relode on a keypress in js
- Category
- JavaScript
- Title
- how to get mouse coordinates in javascript
- Category
- JavaScript
- Title
- how to instialise var in js
- Category
- JavaScript
- Title
- angular one way property binding
- Category
- JavaScript
- Title
- javascript anagram check
- Category
- JavaScript
- Title
- Javascript change element class
- Category
- JavaScript
- Title
- explode in jquery
- Category
- JavaScript
- Title
- comment in react
- Category
- JavaScript
- Title
- edit onclick event
- Category
- JavaScript
- Title
- call javascript function after page load complete
- Category
- JavaScript
- Title
- array.splice javascript
- Category
- JavaScript
- Title
- Is there an “exists” function for jQuery
- Category
- JavaScript
- Title
- get current directory vbscript
- Category
- JavaScript
- Title
- how to auto refresh page in javascript
- Category
- JavaScript
- Title
- how to make actionsheet on cordova forandroid
- Category
- JavaScript
- Title
- how to loop audio in js
- Category
- JavaScript
- Title
- javascript array column
- Category
- JavaScript
- Title
- fix your timestep javascript
- Category
- JavaScript
- Title
- chart js rotating the x axis labels
- Category
- JavaScript
- Title
- cannot read property 'props' of undefined react redux functional component
- Category
- JavaScript
- Title
- D3.js
- Category
- JavaScript
- Title
- how to hide javascript element by class
- Category
- JavaScript
- Title
- bootstrap datepicker can be less than start date
- Category
- JavaScript
- Title
- is sublime text a good editor
- Category
- JavaScript
- Title
- get attribute value jquery
- Category
- JavaScript
- Title
- get keys wher value is true in object in javascript
- Category
- JavaScript
- Title
- how to untick a checkbox with javascript
- Category
- JavaScript
- Title
- how to parse header in node.js lambda
- Category
- JavaScript
- Title
- how to add class to button in javascript
- Category
- JavaScript
- Title
- dynsmic calss in react add
- Category
- JavaScript
- Title
- increase-memory-limit not working node
- Category
- JavaScript
- Title
- array of objects javascript
- Category
- JavaScript
- Title
- how to calculate average of array in javascript
- Category
- JavaScript
- Title
- how to update react context inside functional component
- Category
- JavaScript
- Title
- import react
- Category
- JavaScript
- Title
- angular string contains
- Category
- JavaScript
- Title
- angular generate component
- Category
- JavaScript