index.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>基于Bootstrup 3可预览的HTML5文件上传插件|DEMO_jQuery之家-自由分享jQuery、html5、css3的插件库</title>
  8. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
  9. <link rel="stylesheet" type="text/css" href="css/default.css">
  10. <link href="css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
  11. <!--[if IE]>
  12. <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
  13. <![endif]-->
  14. </head>
  15. <body>
  16. <div class="htmleaf-container">
  17. <header class="htmleaf-header">
  18. <h1>基于Bootstrup 3可预览的HTML5文件上传插件 <span>An enhanced HTML 5 file input for Bootstrap 3.x with file preview, multiple selection, and more features</span></h1>
  19. <div class="htmleaf-links">
  20. <a class="htmleaf-icon icon-htmleaf-home-outline" href="http://www.htmleaf.com/" title="jQuery之家" target="_blank"><span> jQuery之家</span></a>
  21. <a class="htmleaf-icon icon-htmleaf-arrow-forward-outline" href="http://www.htmleaf.com/html5/html5muban/201505091801.html" title="返回下载页" target="_blank"><span> 返回下载页</span></a>
  22. </div>
  23. </header>
  24. <!--<div class="htmleaf-content bgcolor-8">
  25. </div>-->
  26. <div class="container kv-main">
  27. <div class="page-header">
  28. <h2>Bootstrap File Input Example <small></h2>
  29. </div>
  30. <form enctype="multipart/form-data">
  31. <input id="file-0a" class="file" type="file" multiple data-min-file-count="1">
  32. <br>
  33. <button type="submit" class="btn btn-primary">Submit</button>
  34. <button type="reset" class="btn btn-default">Reset</button>
  35. </form>
  36. <hr>
  37. <form enctype="multipart/form-data">
  38. <label>Test invalid input type</label>
  39. <input id="file-0b" class="file" type="text" multiple data-min-file-count="1">
  40. <script>
  41. $(document).on('ready', function(){$("#file-0b").fileinput();});
  42. </script>
  43. </form>
  44. <hr>
  45. <form enctype="multipart/form-data">
  46. <input id="file-0a" class="file" type="file" multiple data-min-file-count="3">
  47. <hr>
  48. <div class="form-group">
  49. <input id="file-0b" class="file" type="file">
  50. </div>
  51. <hr>
  52. <div class="form-group">
  53. <input id="file-1" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="2">
  54. </div>
  55. <hr>
  56. <div class="form-group">
  57. <input id="file-2" type="file" class="file" readonly data-show-upload="false">
  58. </div>
  59. <hr>
  60. <div class="form-group">
  61. <label>Preview File Icon</label>
  62. <input id="file-3" type="file" multiple=true>
  63. </div>
  64. <hr>
  65. <div class="form-group">
  66. <input id="file-4" type="file" class="file" data-upload-url="#">
  67. </div>
  68. <hr>
  69. <div class="form-group">
  70. <button class="btn btn-warning" type="button">Disable Test</button>
  71. <button class="btn btn-info" type="reset">Refresh Test</button>
  72. <button class="btn btn-primary">Submit</button>
  73. <button class="btn btn-default" type="reset">Reset</button>
  74. </div>
  75. <hr>
  76. <div class="form-group">
  77. <input type="file" class="file" id="test-upload" multiple>
  78. <div id="errorBlock" class="help-block"></div>
  79. </div>
  80. <hr>
  81. <div class="form-group">
  82. <input id="file-5" class="file" type="file" multiple data-preview-file-type="any" data-upload-url="#" data-preview-file-icon="">
  83. </div>
  84. </form>
  85. </div>
  86. <div class="related">
  87. <h3>如果你喜欢这个插件,那么你可能也喜欢:</h3>
  88. <a href="http://www.htmleaf.com/jQuery/Layout-Interface/201505011764.html">
  89. <img src="related/1.jpg" width="300" alt="基于bootstrup的响应式jQuery滚动新闻插件"/>
  90. <h3>基于bootstrup的响应式jQuery滚动新闻插件</h3>
  91. </a>
  92. <a href="http://www.htmleaf.com/jQuery/Menu-Navigation/201502281434.html">
  93. <img src="related/2.jpg" width="300" alt="基于Twitter Bootstrap 3的炫酷jQuery下拉列表插件"/>
  94. <h3>基于Twitter Bootstrap 3的炫酷jQuery下拉列表插件</h3>
  95. </a>
  96. </div>
  97. </div>
  98. <script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js"></script>
  99. <script src="js/fileinput.js" type="text/javascript"></script>
  100. <script src="js/fileinput_locale_zh.js" type="text/javascript"></script>
  101. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
  102. <script>
  103. $("#file-0").fileinput({
  104. 'allowedFileExtensions' : ['jpg', 'png','gif'],
  105. });
  106. $("#file-1").fileinput({
  107. uploadUrl: '#', // you must set a valid URL here else you will get an error
  108. allowedFileExtensions : ['jpg', 'png','gif'],
  109. overwriteInitial: false,
  110. maxFileSize: 1000,
  111. maxFilesNum: 10,
  112. //allowedFileTypes: ['image', 'video', 'flash'],
  113. slugCallback: function(filename) {
  114. return filename.replace('(', '_').replace(']', '_');
  115. }
  116. });
  117. /*
  118. $(".file").on('fileselect', function(event, n, l) {
  119. alert('File Selected. Name: ' + l + ', Num: ' + n);
  120. });
  121. */
  122. $("#file-3").fileinput({
  123. showUpload: false,
  124. showCaption: false,
  125. browseClass: "btn btn-primary btn-lg",
  126. fileType: "any",
  127. previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
  128. });
  129. $("#file-4").fileinput({
  130. uploadExtraData: {kvId: '10'}
  131. });
  132. $(".btn-warning").on('click', function() {
  133. if ($('#file-4').attr('disabled')) {
  134. $('#file-4').fileinput('enable');
  135. } else {
  136. $('#file-4').fileinput('disable');
  137. }
  138. });
  139. $(".btn-info").on('click', function() {
  140. $('#file-4').fileinput('refresh', {previewClass:'bg-info'});
  141. });
  142. /*
  143. $('#file-4').on('fileselectnone', function() {
  144. alert('Huh! You selected no files.');
  145. });
  146. $('#file-4').on('filebrowse', function() {
  147. alert('File browse clicked for #file-4');
  148. });
  149. */
  150. $(document).ready(function() {
  151. $("#test-upload").fileinput({
  152. 'showPreview' : false,
  153. 'allowedFileExtensions' : ['jpg', 'png','gif'],
  154. 'elErrorContainer': '#errorBlock'
  155. });
  156. /*
  157. $("#test-upload").on('fileloaded', function(event, file, previewId, index) {
  158. alert('i = ' + index + ', id = ' + previewId + ', file = ' + file.name);
  159. });
  160. */
  161. });
  162. </script>
  163. </body>
  164. </html>