index-bs5.html 9.4 KB

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