index.html 9.1 KB

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