files.js 905 B

123456789101112131415161718192021222324252627
  1. module.exports = require('./header.js') +`
  2. <form id="form" action="#" method="POST" enctype="multipart/form-data">
  3. <input type="file" id="fileInput" name="content" required />
  4. <div id="error" class="hidden"></div>
  5. <button class="g-recaptcha" data-sitekey="{reCaptcha_public}" data-callback="onSubmit" data-action="submit">Submit</button>
  6. </form>
  7. <script>
  8. function onSubmit(token) {
  9. $.ajax({
  10. type: 'POST',
  11. url: '#',
  12. data: new FormData(document.getElementById('form')),
  13. processData: false,
  14. contentType: false,
  15. success: data => {
  16. if (data.err) {
  17. $("#error").text("Error: " +data.err).removeClass("hidden");
  18. } else if (data.id) {
  19. $("#error").text("").addClass("hidden");
  20. document.location.href = "/x/" +data.id;
  21. }
  22. }
  23. });
  24. }
  25. </script>
  26. ` + require('./footer.js');