index.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
  2. <link rel="stylesheet" href="css/jquery.fileupload.css">
  3. <!-- The fileinput-button span is used to style the file input field as button -->
  4. <span class="btn btn-success fileinput-button">
  5. <i class="glyphicon glyphicon-plus"></i>
  6. <span>Select files...</span>
  7. <!-- The file input field used as target for the file upload widget -->
  8. <input id="fileupload" type="file" name="files[]" multiple>
  9. </span>
  10. <br>
  11. <br>
  12. <!-- The global progress bar -->
  13. <div id="progress" class="progress">
  14. <div class="progress-bar progress-bar-success"></div>
  15. </div>
  16. <!-- The container for the uploaded files -->
  17. <div id="files" class="files"></div>
  18. <script src="../jquery/jquery.min.js"></script>
  19. <!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
  20. <script src="js/vendor/jquery.ui.widget.js"></script>
  21. <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
  22. <script src="js/jquery.iframe-transport.js"></script>
  23. <!-- The basic File Upload plugin -->
  24. <script src="js/jquery.fileupload.js"></script>
  25. <script src="../bootstrap/js/bootstrap.min.js"></script>
  26. <script>
  27. /*jslint unparam: true */
  28. /*global window, $ */
  29. $(function () {
  30. 'use strict';
  31. // Change this to the location of your server-side upload handler:
  32. var url = window.location.hostname === 'blueimp.github.io' ?
  33. '//jquery-file-upload.appspot.com/' : 'server/php/';
  34. $('#fileupload').fileupload({
  35. url: url,
  36. dataType: 'json',
  37. done: function (e, data) {
  38. $.each(data.result.files, function (index, file) {
  39. $('<p/>').text(file.name).appendTo('#files');
  40. });
  41. },
  42. progressall: function (e, data) {
  43. var progress = parseInt(data.loaded / data.total * 100, 10);
  44. $('#progress .progress-bar').css(
  45. 'width',
  46. progress + '%'
  47. );
  48. }
  49. }).prop('disabled', !$.support.fileInput)
  50. .parent().addClass($.support.fileInput ? undefined : 'disabled');
  51. });
  52. </script>