SHARE
TWEET

Untitled

a guest Aug 21st, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <input type="file" id="files" name="files" />
  2. <p>
  3. <div id="FIN"></div>
  4.  
  5. <script>
  6. // just use it with text files
  7. var reader = new FileReader();
  8.  
  9. // it gets called when the FileReader is done reading.
  10. reader.onload = function(e) {
  11.       document.getElementById("FIN").innerHTML = reader.result;
  12. }
  13.  
  14. // it gets called when a file is selected
  15. function handleFileSelect(evt) {
  16.       var files = evt.target.files; // FileList object
  17.       reader.readAsText(files[0]);  
  18. }
  19.  
  20. // configure callback function for changes on file selector
  21. document.getElementById('files').addEventListener('change', handleFileSelect, false);
  22.  
  23. </script>
RAW Paste Data
Top