Guest User

Untitled

a guest
Dec 30th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Hi</title>
  5. </head>
  6. <body>
  7.     <div></div>
  8.     <input type="file" name="">
  9. </body>
  10. <script>
  11. var saveData = (function () {
  12.     var a = document.createElement("a");
  13.     document.body.appendChild(a);
  14.     a.style = "display: none";
  15.     return function (data, fileName) {
  16.         var blob = new Blob([data], {type : 'text'}),
  17.             url = window.URL.createObjectURL(blob);
  18.         a.href = url;
  19.         a.download = fileName;
  20.         a.click();
  21.         window.URL.revokeObjectURL(url);
  22.     };
  23. }());
  24.  
  25. var data = { x: 42, s: "hello, world", d: new Date() },
  26.     fileName = "my-download.json";
  27.  
  28.     var input = document.querySelector("input");
  29.     input.addEventListener("change", function () {
  30.     if (this.files && this.files[0]) {
  31.        var myFile = this.files[0];
  32.         var reader = new FileReader();
  33.        
  34.         reader.addEventListener('load', function (e) {
  35.             var str = e.target.result;
  36.  
  37.             var output = str.match(/http:.*\.jpg/g).join("\n");
  38.  
  39.             saveData(output, "output");
  40.  
  41.         });
  42.        
  43.         reader.readAsBinaryString(myFile);
  44.       }  
  45. });
  46. </script>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment