index.html 9.5 KB

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