index.html 9.2 KB

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