upload.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Upload Form</title>
  5. <script>
  6. var intervalId;
  7. function onTick() {
  8. var label = document.getElementById('upload_label');
  9. label.innerHTML += '.';
  10. }
  11. function onUploadSubmit() {
  12. document.getElementById('upload_target').contentWindow.document.body.
  13. innerHTML = '';
  14. var label = document.getElementById('upload_label');
  15. label.innerHTML = 'Uploading "' + document.forms[0].upload.value + '"';
  16. label.style.display = '';
  17. intervalId = window.setInterval(onTick, 500);
  18. return true;
  19. }
  20. function onUploadDone() {
  21. var label = document.getElementById('upload_label');
  22. label.style.display = 'none';
  23. window.clearInterval(intervalId);
  24. return true;
  25. }
  26. </script>
  27. </head>
  28. <body>
  29. <form action="/common/upload" method="post" name="upload_form"
  30. target="upload_target" enctype="multipart/form-data"
  31. onsubmit="onUploadSubmit();">
  32. <div>
  33. Enter a file to upload:
  34. <div><input id="upload" name="upload" type="file"/></div>
  35. <div><input id="go" type="submit" value="Go!"/></div>
  36. </div>
  37. <div id="upload_label" style="display:none"></div>
  38. <iframe src="" id="upload_target" name="upload_target"
  39. style="width:300px;height:200px">
  40. </iframe>
  41. </form>
  42. </body>
  43. </html>