index-bs5.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 - Bootstrap 5.x - &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="../js/plugins/piexif.js" type="text/javascript"></script>
  23. <script src="../js/plugins/sortable.js" type="text/javascript"></script>
  24. </head>
  25. <body>
  26. <div class="container my-4">
  27. <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
  28. <script src="../js/fileinput.js" type="text/javascript"></script>
  29. <script src="../js/locales/fr.js" type="text/javascript"></script>
  30. <script src="../js/locales/es.js" type="text/javascript"></script>
  31. <script src="../themes/fas/theme.js" type="text/javascript"></script>
  32. <script src="../themes/explorer-fas/theme.js" type="text/javascript"></script>
  33. <h1>Bootstrap File Input Examples
  34. <small><a href="https://github.com/kartik-v/bootstrap-fileinput-samples"><i
  35. class="glyphicon glyphicon-download"></i> Download Sample Files</a></small>
  36. </h1>
  37. <h4>Bootstrap Version: <script>document.write($.fn.fileinputBsVersion);</script></h4>
  38. <hr>
  39. <form enctype="multipart/form-data">
  40. <div class="file-loading">
  41. <input id="kv-explorer" type="file" multiple>
  42. </div>
  43. <br>
  44. <div class="file-loading">
  45. <input id="file-0a" class="file" type="file" multiple data-min-file-count="1">
  46. </div>
  47. <br>
  48. <button type="submit" class="btn btn-primary">Submit</button>
  49. <button type="reset" class="btn btn-outline-secondary">Reset</button>
  50. </form>
  51. <hr>
  52. <h5>Preupload Validation</h5>
  53. <input id="file-0" name="file-0" type="file">
  54. <br>
  55. <textarea id="description" rows=3" class="form-control" placeholder="Enter description for the files selected..."></textarea>
  56. <br>
  57. <form enctype="multipart/form-data" action="">
  58. <label for="file-0b">Test invalid input type</label>
  59. <div class="file-loading">
  60. <input id="file-0b" name="file-0b" class="file" type="text" multiple data-min-file-count="1">
  61. </div>
  62. <script>
  63. $(document).on('ready', function () {
  64. $("#file-0b").fileinput();
  65. });
  66. </script>
  67. </form>
  68. <hr>
  69. <form enctype="multipart/form-data" action="http://localhost/plugins/test">
  70. <div class="file-loading">
  71. <input id="file-0c" class="file" type="file" multiple data-min-file-count="3">
  72. </div>
  73. <hr>
  74. <div class="form-group">
  75. <div class="file-loading">
  76. <input id="file-0d" class="file" type="file">
  77. </div>
  78. </div>
  79. <hr>
  80. <div class="form-group">
  81. <div class="file-loading">
  82. <input id="file-1" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="2">
  83. </div>
  84. </div>
  85. <hr>
  86. <div class="form-group">
  87. <div class="file-loading">
  88. <input id="file-2" type="file" class="file" readonly data-show-upload="false">
  89. </div>
  90. </div>
  91. <hr>
  92. <div class="form-group">
  93. <label for="file-3">Batch Preupload Error Check</label>
  94. <div class="file-loading">
  95. <input id="file-3" type="file" multiple>
  96. </div>
  97. </div>
  98. <hr>
  99. <div class="form-group">
  100. <div class="file-loading">
  101. <input id="file-4" type="file" class="file" data-upload-url="#">
  102. </div>
  103. </div>
  104. <hr>
  105. <div class="form-group">
  106. <button class="btn btn-warning" type="button">Disable Test</button>
  107. <button class="btn btn-info" type="reset">Refresh Test</button>
  108. <button class="btn btn-primary">Submit</button>
  109. <button class="btn btn-outline-secondary" type="reset">Reset</button>
  110. </div>
  111. <hr>
  112. <div class="form-group">
  113. <div class="file-loading">
  114. <input type="file" class="file" id="test-upload" multiple>
  115. </div>
  116. <div id="errorBlock" class="help-block"></div>
  117. </div>
  118. <hr>
  119. <div class="form-group">
  120. <div class="file-loading">
  121. <input id="file-5" class="file" type="file" multiple data-preview-file-type="any" data-upload-url="#">
  122. </div>
  123. </div>
  124. </form>
  125. <hr>
  126. <h4>Multi Language Inputs</h4>
  127. <form enctype="multipart/form-data">
  128. <label>French Input</label>
  129. <div class="file-loading">
  130. <input id="file-fr" name="file-fr[]" type="file" multiple>
  131. </div>
  132. <hr style="border: 2px dotted">
  133. <label>Spanish Input</label>
  134. <div class="file-loading">
  135. <input id="file-es" name="file-es[]" type="file" multiple>
  136. </div>
  137. </form>
  138. <hr>
  139. <br>
  140. </div>
  141. </body>
  142. <script>
  143. $('#file-fr').fileinput({
  144. theme: 'fas',
  145. language: 'fr',
  146. uploadUrl: '#',
  147. allowedFileExtensions: ['jpg', 'png', 'gif']
  148. });
  149. $('#file-es').fileinput({
  150. theme: 'fas',
  151. language: 'es',
  152. uploadUrl: '#',
  153. allowedFileExtensions: ['jpg', 'png', 'gif']
  154. });
  155. $("#file-0").fileinput({
  156. theme: 'fas',
  157. uploadUrl: '#'
  158. }).on('filepreupload', function(event, data, previewId, index) {
  159. alert('The description entered is:\n\n' + ($('#description').val() || ' NULL'));
  160. });
  161. $("#file-1").fileinput({
  162. theme: 'fas',
  163. uploadUrl: '#', // you must set a valid URL here else you will get an error
  164. allowedFileExtensions: ['jpg', 'png', 'gif'],
  165. overwriteInitial: false,
  166. maxFileSize: 1000,
  167. maxFilesNum: 10,
  168. //allowedFileTypes: ['image', 'video', 'flash'],
  169. slugCallback: function (filename) {
  170. return filename.replace('(', '_').replace(']', '_');
  171. }
  172. });
  173. /*
  174. $(".file").on('fileselect', function(event, n, l) {
  175. alert('File Selected. Name: ' + l + ', Num: ' + n);
  176. });
  177. */
  178. $("#file-3").fileinput({
  179. theme: 'fas',
  180. browseClass: "btn btn-primary",
  181. overwriteInitial: false,
  182. initialPreviewAsData: true,
  183. //uploadUrl: 'http://localhost/plugins/test-upload',
  184. initialPreview: [
  185. "http://lorempixel.com/640/360/transport/1",
  186. "http://lorempixel.com/640/360/transport/2",
  187. "http://lorempixel.com/640/360/transport/3"
  188. ],
  189. initialPreviewConfig: [
  190. {caption: "transport-1.jpg", size: 329892, width: "120px", url: "{$url}", key: 1, zoomData: 'http://lorempixel.com/1920/1080/transport/1', description: '<h5>NUMBER 1</h5> The first choice for transport. This is the future.'},
  191. {caption: "transport-2.jpg", size: 872378, width: "120px", url: "{$url}", key: 2, zoomData: 'http://lorempixel.com/1920/1080/transport/2', description: '<h5>NUMBER 2</h5> The second choice for transport. This is the future.'},
  192. {caption: "transport-3.jpg", size: 632762, width: "120px", url: "{$url}", key: 3, zoomData: 'http://lorempixel.com/1920/1080/transport/3', description: '<h5>NUMBER 3</h5> The third choice for transport. This is the future.'}
  193. ]
  194. }).on('filebatchpreupload', function(e, data) {
  195. return {
  196. message: 'Error here',
  197. data: data
  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>