filereader javascript example
'use strict'
const fs = require('fs');
let fileContent = fs.readFileSync('/path/to/myfile', 'utf-8');
console.log(fileContent);//HTML
<input type='file' accept='image/*' onchange='openFile(event)'><br>
<img id='output'>
//Javascript
var openFile = function(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function(){
var dataURL = reader.result;
var output = document.getElementById('output');
output.src = dataURL;
};
reader.readAsDataURL(input.files[0]);
}
Also in JavaScript:
- react native create button
- decimal to base 32 javascript
- How to get row index and cellindex together in javascript
- difference between ajax and node js
- jquery create input hidden
- using aria attributes in angular
- js selection box excel node
- javascript buttons
- Lazy Loading Routes vue
- javascript change class of item
- react native toggle button with text
- node js interview questions
- settimeout node js
- how to count duplicates in an array javascript
- mongoose nullable
- how To fetch the index of dropdown using jquery
- cypress
- js paste event
- javascript function multiple parameters
- open html file in browser using package.json
- javascript copy an object without reference
- vuejs nested v-for
- javascript hashtable contains key
- how to send post request js fetch