index-bs5.html 9.9 KB

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