reading files in javascript
'use strict'
const fs = require('fs');
let fileContent = fs.readFileSync('/path/to/myfile', 'utf-8');
console.log(fileContent);const fileList = event.target.files;
let fileContent = "";
const fr = new FileReader();
fr.onload = () => {
fileContent = fr.result;
console.log('Commands', fileContent);
}
fr.readAsText(fileList[0]);<embed src="file.txt"> // This will show the text contained in file.txt in the page
Also in JavaScript:
- js check if string contains character
- Lazy Loading Routes vue
- negative reciprocal javascript
- get screen resolution jquery
- react redirect after login
- jquery copier dans le presse papier
- measure width in px chrome extension
- javascript var in quotes
- javascript add new element to object
- $(...).autocomplete is not a function
- jquery set checkbox checked unchecked
- sequelize include only
- pass props in react
- eslint ignore current line
- react conditional if localhost
- javascript copy array map
- get name jquery
- axios get array of urls
- javascript json decode
- react keydown event listener
- return uncommon from two arrays js
- jquery loop through list element
- print value in jquery
- tor in node.js