index-bs4.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 - &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="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
  15. <script src="../js/plugins/piexif.js" type="text/javascript"></script>
  16. <script src="../js/plugins/sortable.js" type="text/javascript"></script>
  17. <script src="../js/fileinput.js" type="text/javascript"></script>
  18. <script src="../js/locales/fr.js" type="text/javascript"></script>
  19. <script src="../js/locales/es.js" type="text/javascript"></script>
  20. <script src="../themes/fas/theme.js" type="text/javascript"></script>
  21. <script src="../themes/explorer-fas/theme.js" type="text/javascript"></script>
  22. </head>
  23. <body>
  24. <div class="container my-4">
  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" data-theme="fas">
  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">
  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" data-theme="fas">
  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">
  62. <div class="file-loading">
  63. <input id="file-0c" class="file" type="file" multiple data-min-file-count="3" data-theme="fas">
  64. </div>
  65. <hr>
  66. <div class="form-group">
  67. <div class="file-loading">
  68. <input id="file-0d" class="file" type="file" data-theme="fas">
  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" data-theme="fas">
  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" data-theme="fas">
  81. </div>
  82. </div>
  83. <hr>
  84. <div class="form-group">
  85. <div class="file-loading">
  86. <label>Preview File Icon</label>
  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="#" data-theme="fas">
  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 data-theme="fas">
  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="#" data-theme="fas">
  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. showUpload: false,
  173. showCaption: false,
  174. browseClass: "btn btn-primary btn-lg",
  175. fileType: "any",
  176. previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
  177. overwriteInitial: false,
  178. initialPreviewAsData: true,
  179. initialPreview: [
  180. "http://lorempixel.com/1920/1080/transport/1",
  181. "http://lorempixel.com/1920/1080/transport/2",
  182. "http://lorempixel.com/1920/1080/transport/3"
  183. ],
  184. initialPreviewConfig: [
  185. {caption: "transport-1.jpg", size: 329892, width: "120px", url: "{$url}", key: 1},
  186. {caption: "transport-2.jpg", size: 872378, width: "120px", url: "{$url}", key: 2},
  187. {caption: "transport-3.jpg", size: 632762, width: "120px", url: "{$url}", key: 3}
  188. ]
  189. });
  190. $("#file-4").fileinput({
  191. theme: 'fas',
  192. uploadExtraData: {kvId: '10'}
  193. });
  194. $(".btn-warning").on('click', function () {
  195. var $el = $("#file-4");
  196. if ($el.attr('disabled')) {
  197. $el.fileinput('enable');
  198. } else {
  199. $el.fileinput('disable');
  200. }
  201. });
  202. $(".btn-info").on('click', function () {
  203. $("#file-4").fileinput('refresh', {previewClass: 'bg-info'});
  204. });
  205. /*
  206. $('#file-4').on('fileselectnone', function() {
  207. alert('Huh! You selected no files.');
  208. });
  209. $('#file-4').on('filebrowse', function() {
  210. alert('File browse clicked for #file-4');
  211. });
  212. */
  213. $(document).ready(function () {
  214. $("#test-upload").fileinput({
  215. 'theme': 'fas',
  216. 'showPreview': false,
  217. 'allowedFileExtensions': ['jpg', 'png', 'gif'],
  218. 'elErrorContainer': '#errorBlock'
  219. });
  220. $("#kv-explorer").fileinput({
  221. 'theme': 'explorer-fas',
  222. 'uploadUrl': '#',
  223. overwriteInitial: false,
  224. initialPreviewAsData: true,
  225. initialPreview: [
  226. "http://lorempixel.com/1920/1080/nature/1",
  227. "http://lorempixel.com/1920/1080/nature/2",
  228. "http://lorempixel.com/1920/1080/nature/3"
  229. ],
  230. initialPreviewConfig: [
  231. {caption: "nature-1.jpg", size: 329892, width: "120px", url: "{$url}", key: 1},
  232. {caption: "nature-2.jpg", size: 872378, width: "120px", url: "{$url}", key: 2},
  233. {caption: "nature-3.jpg", size: 632762, width: "120px", url: "{$url}", key: 3}
  234. ]
  235. });
  236. /*
  237. $("#test-upload").on('fileloaded', function(event, file, previewId, index) {
  238. alert('i = ' + index + ', id = ' + previewId + ', file = ' + file.name);
  239. });
  240. */
  241. });
  242. </script>
  243. </html>