Guest User

Untitled

a guest
Feb 4th, 2020
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <link rel='icon' href='data:;base64,=' />
  2. <script src='http://code.jquery.com/jquery-3.1.0.min.js'></script>
  3. <script>
  4. function attach() {
  5. $('#up').on('click',function() {
  6. var f=$('#upfile')[0].files[0];
  7. $.ajax('/upload',
  8.  {
  9.  method:'POST',
  10.  data:f,
  11.  contentType:false,
  12.  processData:false,
  13.  statusCode: {201:function(){$('#status').text(f.name+': Success!');setTimeout(r,1000);}}
  14.  });
  15. });
  16. $('#c').on('click',function() {
  17. var f=$('#comment')[0].value;
  18. var fl=$('#view')[0].contentWindow.location.pathname;
  19. $.ajax(fl, {
  20.  method:'PUT',
  21.  contentType:"text/plain",
  22.  data:f,
  23.  statusCode: {201:function(){setTimeout(r,1000);}}
  24.  });
  25. });
  26. $('#view').on('load',function() {
  27.  console.log('view:load');
  28.  var l=$('#view')[0].contentWindow.location.pathname;
  29.  var lc="/?c="+l.slice(1);
  30.  $.get(lc).done((data)=>{$('pre').text(data);$('pre').css({"display":"none"});});
  31. });
  32. $('#vfocus').on('mouseenter',()=>$('pre').css("display","block"))
  33.  .on('mouseleave',()=>$('pre').css("display","none"));
  34. }
  35. function r() {window.location.reload(false);}
  36. </script>
  37. <style>p{font-family:sans-serif;font-size:small;width:50%;}
  38. div#upload{width:50%;margin:2.5%;border:1px solid black;padding:0.5%;}
  39. div#images{width:100%;height:auto;}
  40. img{max-width:300px;max-height:300px;padding:0.5%;}
  41. iframe{float:right;width:50%;height:70%;margin:0% 0.5%;border:none;}
  42. footer{float:right;width:50%;padding:0.5%;}
  43. </style>
  44. <body onload='attach();'>
  45. <div id='upload'><input type='file' id='upfile' /> <input id='up' type='button' value='Senden' />
  46. <p id='status'>Upload an image/video file.</p><noscript><em>But first enable JavaScript!</em></noscript></div>
  47. <p>Received images:</p><br/>
  48. <a id='vfocus'><iframe src='about:blank' id='view' name='view'></iframe>
  49. <footer><input style='border:1px solid grey;' type='text' id='comment' /><input id='c' type='button' value='OK' /><pre></pre></footer></a>
  50. </body>
RAW Paste Data