Guest User

Untitled

a guest
Nov 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <form><input type='file' id="poem" accept='text/plain' onchange='printPoem(event)' ></form>
  2.  
  3. <script>
  4. if (filename !== null){
  5. document.getElementById("getfilename").innerHTML = filename;
  6. //document.write(filename);
  7. }
  8. </script>
  9.  
  10. function printPoem(event) {
  11. var input = event.target;
  12. var reader = new FileReader();
  13. reader.onload = function(){
  14. var text = reader.result;
  15. //document.write(reader.result.substring(0, 200));
  16. var fullPath = document.getElementById("poem").value;
  17.  
  18. if (fullPath) {
  19. var startIndex = (fullPath.indexOf('\') >= 0 ?
  20. fullPath.lastIndexOf('\') : fullPath.lastIndexOf('/'));
  21. filename = fullPath.substring(startIndex);
  22. if (filename.indexOf('\') === 0 || filename.indexOf('/') === 0) {
  23. filename = filename.substring(1);
  24. }
  25. //alert(filename);
  26. }
  27. document.getElementById("displayPoem").innerHTML = text;
  28. };
  29. reader.readAsText(input.files[0]);
  30. return(filename);
  31.  
  32. <input type="button" class="button" value="Visualize" onclick="window.location.href='visualization.html'">
Add Comment
Please, Sign In to add comment