javascript function to open file browser
const browseFiles = () => {
var input = document.createElement('input');
input.type = 'file';
input.click();
}function readSingleFile(e) {
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
displayContents(contents);
};
reader.readAsText(file);
}
function displayContents(contents) {
var element = document.getElementById('file-content');
element.textContent = contents;
}
document.getElementById('file-input')
.addEventListener('change', readSingleFile, false);window.open("file:///D:/Hello.txt");
Also in JavaScript:
- puppeteer js
- js index sorted
- javascript switch items in array
- jquery on wheel event
- detecting change in animated value react native
- react native margin
- javascript create object empty
- javascript setattribute
- convert arrow function to normal function javascript online
- javascript keypress backspace not working
- math.round js 1 decimal
- vanilla javascript jwt authentication laravel
- get a element using name in jquery
- promise states javascript
- how to place text at custom position on canvas in javascript
- bootstrap dropdown not working in angular 8
- You are running Node 8.10.0. Create React App requires Node 10 or higher. Please update your version of Node.
- jquery-3.4.1.min.js
- last index of array js
- the path argument must be of type string. received undefined react
- buble sort in js
- js keyframe
- toggle function react js
- random number js