index-bs3.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!--
  2. * bootstrap-fileinput v5.2.7
  3. * http://plugins.krajee.com/file-input
  4. *
  5. * Author: Kartik Visweswaran
  6. * Copyright: 2014 - 2021, Kartik Visweswaran, Krajee.com
  7. *
  8. * Licensed under the BSD-3-Clause
  9. * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
  10. -->
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="UTF-8"/>
  15. <title>Krajee JQuery Plugins - &copy; Kartik</title>
  16. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" crossorigin="anonymous">
  17. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" crossorigin="anonymous">
  18. <link href="../css/fileinput.css" media="all" rel="stylesheet" type="text/css"/>
  19. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous">
  20. <link href="../themes/explorer-fas/theme.css" media="all" rel="stylesheet" type="text/css"/>
  21. <script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
  22. <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" crossorigin="anonymous"></script>
  23. <script src="../js/plugins/piexif.js" type="text/javascript"></script>
  24. <script src="../js/plugins/sortable.js" type="text/javascript"></script>
  25. <script src="../js/fileinput.js" type="text/javascript"></script>
  26. <script src="../js/locales/fr.js" type="text/javascript"></script>
  27. <script src="../js/locales/es.js" type="text/javascript"></script>
  28. <script src="../themes/gly/theme.js" type="text/javascript"></script>
  29. <script src="../themes/fas/theme.js" type="text/javascript"></script>
  30. <script src="../themes/explorer-fas/theme.js" type="text/javascript"></script>
  31. <script>$.fn.fileinput.defaults.theme = 'gly';</script>
  32. </head>
  33. <body>
  34. <div class="container my-4">
  35. <h1>Bootstrap File Input Examples
  36. <small><a href="https://github.com/kartik-v/bootstrap-fileinput-samples"><i
  37. class="glyphicon glyphicon-download"></i> Download Sample Files</a></small>
  38. </h1>
  39. <h4>Bootstrap Version: <script>document.write($.fn.fileinputBsVersion);</script></h4>
  40. <hr>
  41. <form enctype="multipart/form-data">
  42. <div class="file-loading">
  43. <input id="kv-explorer" type="file" multiple>
  44. </div>
  45. <br>
  46. <div class="file-loading">
  47. <input id="file-0a" class="file" type="file" multiple data-min-file-count="1" data-theme="fas">
  48. </div>
  49. <br>
  50. <button type="submit" class="btn btn-primary">Submit</button>
  51. <button type="reset" class="btn btn-outline-secondary">Reset</button>
  52. </form>
  53. <hr>
  54. <h5>Preupload Validation</h5>
  55. <input id="file-0" name="file-0" type="file">
  56. <br>
  57. <textarea id="description" rows=3" class="form-control" placeholder="Enter description for the files selected..."></textarea>
  58. <br>
  59. <form enctype="multipart/form-data">
  60. <label for="file-0b">Test invalid input type</label>
  61. <div class="file-loading">
  62. <input id="file-0b" name="file-0b" class="file" type="text" multiple data-min-file-count="1">
  63. </div>
  64. <script>
  65. $(document).on('ready', function () {
  66. $("#file-0b").fileinput();
  67. });
  68. </script>
  69. </form>
  70. <hr>
  71. <form enctype="multipart/form-data">
  72. <div class="file-loading">
  73. <input id="file-0c" class="file" type="file" multiple data-min-file-count="3" data-theme="gly">
  74. </div>
  75. <hr>
  76. <div class="form-group">
  77. <div class="file-loading">
  78. <input id="file-0d" class="file" type="file">
  79. </div>
  80. </div>
  81. <hr>
  82. <div class="form-group">
  83. <div class="file-loading">
  84. <input id="file-1" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="2" data-theme="fas">
  85. </div>
  86. </div>
  87. <hr>
  88. <div class="form-group">
  89. <div class="file-loading">
  90. <input id="file-2" type="file" class="file" readonly data-show-upload="false" data-theme="fas">
  91. </div>
  92. </div>
  93. <hr>
  94. <div class="form-group">
  95. <div class="file-loading">
  96. <label>Preview File Icon</label>
  97. <input id="file-3" type="file" multiple>
  98. </div>
  99. </div>
  100. <hr>
  101. <div class="form-group">
  102. <div class="file-loading">
  103. <input id="file-4" type="file" class="file" data-upload-url="#" data-theme="fas">
  104. </div>
  105. </div>
  106. <hr>
  107. <div class="form-group">
  108. <button class="btn btn-warning" type="button">Disable Test</button>
  109. <button class="btn btn-info" type="reset">Refresh Test</button>
  110. <button class="btn btn-primary">Submit</button>
  111. <button class="btn btn-outline-secondary" type="reset">Reset</button>
  112. </div>
  113. <hr>
  114. <div class="form-group">
  115. <div class="file-loading">
  116. <input type="file" class="file" id="test-upload" multiple data-theme="fas">
  117. </div>
  118. <div id="errorBlock" class="help-block"></div>
  119. </div>
  120. <hr>
  121. <div class="form-group">
  122. <div class="file-loading">
  123. <input id="file-5" class="file" type="file" multiple data-preview-file-type="any" data-upload-url="#" data-theme="fas">
  124. </div>
  125. </div>
  126. </form>
  127. <hr>
  128. <h4>Multi Language Inputs</h4>
  129. <form enctype="multipart/form-data">
  130. <label>French Input</label>
  131. <div class="file-loading">
  132. <input id="file-fr" name="file-fr[]" type="file" multiple>
  133. </div>
  134. <hr style="border: 2px dotted">
  135. <label>Spanish Input</label>
  136. <div class="file-loading">
  137. <input id="file-es" name="file-es[]" type="file" multiple>
  138. </div>
  139. </form>
  140. <hr>
  141. <br>
  142. </div>
  143. </body>
  144. <script>
  145. $('#file-fr').fileinput({
  146. theme: 'fas',
  147. language: 'fr',
  148. uploadUrl: '#',
  149. allowedFileExtensions: ['jpg', 'png', 'gif']
  150. });
  151. $('#file-es').fileinput({
  152. theme: 'fas',
  153. language: 'es',
  154. uploadUrl: '#',
  155. allowedFileExtensions: ['jpg', 'png', 'gif']
  156. });
  157. $("#file-0").fileinput({
  158. theme: 'fas',
  159. uploadUrl: '#'
  160. }).on('filepreupload', function(event, data, previewId, index) {
  161. alert('The description entered is:\n\n' + ($('#description').val() || ' NULL'));
  162. });
  163. $("#file-1").fileinput({
  164. theme: 'fas',
  165. uploadUrl: '#', // you must set a valid URL here else you will get an error
  166. allowedFileExtensions: ['jpg', 'png', 'gif'],
  167. overwriteInitial: false,
  168. maxFileSize: 1000,
  169. maxFilesNum: 10,
  170. //allowedFileTypes: ['image', 'video', 'flash'],
  171. slugCallback: function (filename) {
  172. return filename.replace('(', '_').replace(']', '_');
  173. }
  174. });
  175. /*
  176. $(".file").on('fileselect', function(event, n, l) {
  177. alert('File Selected. Name: ' + l + ', Num: ' + n);
  178. });
  179. */
  180. $("#file-3").fileinput({
  181. theme: 'fas',
  182. showUpload: false,
  183. showCaption: false,
  184. browseClass: "btn btn-primary btn-lg",
  185. fileType: "any",
  186. previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
  187. overwriteInitial: false,
  188. initialPreviewAsData: true,
  189. initialPreview: [
  190. "http://lorempixel.com/1920/1080/transport/1",
  191. "http://lorempixel.com/1920/1080/transport/2",
  192. "http://lorempixel.com/1920/1080/transport/3"
  193. ],
  194. initialPreviewConfig: [
  195. {caption: "transport-1.jpg", size: 329892, width: "120px", url: "{$url}", key: 1},
  196. {caption: "transport-2.jpg", size: 872378, width: "120px", url: "{$url}", key: 2},
  197. {caption: "transport-3.jpg", size: 632762, width: "120px", url: "{$url}", key: 3}
  198. ]
  199. });
  200. $("#file-4").fileinput({
  201. theme: 'fas',
  202. uploadExtraData: {kvId: '10'}
  203. });
  204. $(".btn-warning").on('click', function () {
  205. var $el = $("#file-4");
  206. if ($el.attr('disabled')) {
  207. $el.fileinput('enable');
  208. } else {
  209. $el.fileinput('disable');
  210. }
  211. });
  212. $(".btn-info").on('click', function () {
  213. $("#file-4").fileinput('refresh', {previewClass: 'bg-info'});
  214. });
  215. /*
  216. $('#file-4').on('fileselectnone', function() {
  217. alert('Huh! You selected no files.');
  218. });
  219. $('#file-4').on('filebrowse', function() {
  220. alert('File browse clicked for #file-4');
  221. });
  222. */
  223. $(document).ready(function () {
  224. $("#test-upload").fileinput({
  225. 'theme': 'fas',
  226. 'showPreview': false,
  227. 'allowedFileExtensions': ['jpg', 'png', 'gif'],
  228. 'elErrorContainer': '#errorBlock'
  229. });
  230. $("#kv-explorer").fileinput({
  231. 'theme': 'explorer-fas',
  232. 'uploadUrl': '#',
  233. overwriteInitial: false,
  234. initialPreviewAsData: true,
  235. initialPreview: [
  236. "http://lorempixel.com/1920/1080/nature/1",
  237. "http://lorempixel.com/1920/1080/nature/2",
  238. "http://lorempixel.com/1920/1080/nature/3"
  239. ],
  240. initialPreviewConfig: [
  241. {caption: "nature-1.jpg", size: 329892, width: "120px", url: "{$url}", key: 1},
  242. {caption: "nature-2.jpg", size: 872378, width: "120px", url: "{$url}", key: 2},
  243. {caption: "nature-3.jpg", size: 632762, width: "120px", url: "{$url}", key: 3}
  244. ]
  245. });
  246. /*
  247. $("#test-upload").on('fileloaded', function(event, file, previewId, index) {
  248. alert('i = ' + index + ', id = ' + previewId + ', file = ' + file.name);
  249. });
  250. */
  251. });
  252. </script>
  253. </html>