Advertisement
Guest User

Untitled

a guest
May 5th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. function gotFile(file){
  2. readAsText(file);
  3. }
  4.  
  5. function readAsText(file) {
  6. var reader = new FileReader();
  7. reader.onloadend = function() {
  8. var string = evt.target.result;
  9. };
  10. alert(string) // returns null
  11. reader.readAsText(file);
  12. }
  13.  
  14. function gotFile(file){
  15. readAsText(file,function(str){
  16. return str;
  17. });
  18. }
  19.  
  20. function readAsText(file,callback) {
  21. var reader = new FileReader();
  22. reader.onloadend = function() {
  23. callback(reader.result);
  24. };
  25. reader.readAsText(file);
  26. alert(callback);
  27. }
  28.  
  29. function(str){
  30. return str;
  31. }
  32.  
  33. function gotFile(file){
  34. readAsText(file,function(str){
  35. alert(str);
  36. });
  37. }
  38.  
  39. function readAsText(file,callback) {
  40. var reader = new FileReader();
  41. reader.onloadend = function() {
  42. callback(reader.result);
  43. };
  44. reader.readAsText(file);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement