Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript function to open file browser

const browseFiles = () => {
  var input = document.createElement('input');
  input.type = 'file';
  input.click();
}
Comment

javascript how to open a file

window.open("file:///D:/Hello.txt");
Comment

javascript how to open a file

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: lodash remove null from object 
Javascript :: javascript set variable if not defined 
Javascript :: jQuery hasClass() - check for more than one class 
Javascript :: is checked checkbox jquery 
Javascript :: string concatenation javascript 
Javascript :: base64 to blob 
Javascript :: express server 
Javascript :: react current path 
Javascript :: vuejs check object key exist 
Javascript :: javascript and operator 
Javascript :: downgrade nodejs with nvm 
Javascript :: get first 10 characters of string javascript 
Javascript :: javascript random text from array 
Javascript :: useeffect only on mount 
Javascript :: react native run ios 
Javascript :: adding styling to element using javascript 
Javascript :: js array find regex 
Javascript :: using .env in cra 
Javascript :: remove comma from string jquery 
Javascript :: javascript is array empty 
Javascript :: what is the use of bind method in javascript 
Javascript :: regex to find emails 
Javascript :: window load 
Javascript :: tribonacci sequence javascript 
Javascript :: javascript tostring method 
Javascript :: async awiat 
Javascript :: vue call method after render 
Javascript :: mongodb replace string regex 
Javascript :: npm got 
Javascript :: file name in react input 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =