Installations
npm install bootstrap-fileinput
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.10.0
NPM Version
10.2.3
Score
85.1
Supply Chain
99.3
Quality
77.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (93.67%)
SCSS (3.27%)
CSS (2.94%)
Batchfile (0.11%)
Developer
Download Statistics
Total Downloads
2,320,124
Last Day
1,591
Last Week
7,270
Last Month
30,536
Last Year
397,133
GitHub Statistics
5,365 Stars
1,307 Commits
2,389 Forks
375 Watching
3 Branches
138 Contributors
Bundle Size
132.15 kB
Minified
40.67 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.5.4
Package Id
bootstrap-fileinput@5.5.4
Unpacked Size
1.51 MB
Size
340.15 kB
File Count
101
NPM Version
10.2.3
Node Version
20.10.0
Publised On
09 Apr 2024
Total Downloads
Cumulative downloads
Total Downloads
2,320,124
Last day
-4.6%
1,591
Compared to previous day
Last week
-10.4%
7,270
Compared to previous week
Last month
7.4%
30,536
Compared to previous month
Last year
-9.6%
397,133
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
bootstrap-fileinput
  Â
An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with file preview for various files, offers multiple selection, resumable chunk uploads, and more. The plugin allows you a simple way to setup an advanced file picker/upload control built to work specially with Bootstrap 5.x, 4.x, and 3.x CSS3 styles. It enhances the file input functionality further, by offering support to preview a wide variety of files i.e. images, text, html, video, audio, flash, and objects. In addition, it includes AJAX based uploads, dragging & dropping files, viewing upload progress, and selectively previewing, adding, or deleting files.
NEW: Bootstrap 5.x support is added from v5.2.0 (major release after v5.1.5) of the plugin. With v5.2.0, the plugin is able to automatically detect the bootstrap library version and deliver the relevant bootstrap specific functionality (if the bootstrap library JS file is loaded). Alternatively, check the
$.fn.fileinputBsVersion
setting for advanced use cases to avoid Bootstrap version detection issues.
NOTE: Version 5.x is a significant rewrite. With version 5.x, the plugin code has been revamped with enhanced file management, resumable chunk uploads support, and other new features. You can go through the various closed enhancements and features and documented for Release 5.x milestone.
NOTE: An alternative new Krajee Explorer Theme (preview shown below) for
bootstrap-fileinput
has been released and available since v4.3.7. For more theming options and suggestions refer the theming demos.
Documentation and Demo
View the plugin documentation and plugin demos at Krajee JQuery plugins.
Pre-requisites
- Bootstrap 5.x or 4.x, or 3.x
- Latest JQuery
- Most modern browsers supporting HTML5 (inputs and FileReader API) including CSS3 & JQuery. For Internet Explorer, one must use IE versions 10 and above. IE9 and below will work as a normal file input, and will not support multiple file selection or the HTML 5 FileReader API.
- With release 4.0, AJAX uploads are supported. AJAX uploads require that the browser support HTML5 FormData and XHR2 (XMLHttpRequest 2). Most modern browsers support FormData and XHR2. The plugin will automatically degrade to normal form based submission for browsers not supporting AJAX uploads
NOTE:
- Bootstrap 5.x is supported in addition to Bootstrap 3.x and 4.x since release v5.2.0. Refer the CHANGE LOG for details.
- Bootstrap 4.x is supported in addition to Bootstrap 3.x since release v4.4.4. Refer the CHANGE LOG for details.
- You can use the sass branch for installation using
bootstrap-sass
dependency. The master branch can be used for installation using plainbootstrap
dependency.
Installation
Using Bower
To install using the bower
package manager run:
bower install bootstrap-fileinput
Using NPM
To install using the npm
package manager run:
npm install bootstrap-fileinput
Using Composer
To install using the composer
package manager run:
$ php composer.phar require kartik-v/bootstrap-fileinput "@dev"
or add:
"kartik-v/bootstrap-fileinput": "@dev"
to your composer.json file
Manual Install
You can also manually install the plugin easily to your project. Just download the source ZIP or TAR ball and extract the plugin assets (css and js folders) into your project.
Usage
Step 1: Load the following assets on your page in the order mentioned.
1<!-- bootstrap 5.x or 4.x is supported. You can also use the bootstrap css 3.3.x versions --> 2<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous"> 3 4<!-- default icons used in the plugin are from Bootstrap 5.x icon library (which can be enabled by loading CSS below) --> 5<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.min.css" crossorigin="anonymous"> 6 7<!-- alternatively you can use the font awesome icon library if using with `fas` theme (or Bootstrap 4.x) by uncommenting below. --> 8<!-- link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous" --> 9 10<!-- the fileinput plugin styling CSS file --> 11<link href="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" /> 12 13<!-- if using RTL (Right-To-Left) orientation, load the RTL CSS file after fileinput.css by uncommenting below --> 14<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /--> 15 16<!-- the jQuery Library --> 17<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script> 18 19<!-- buffer.min.js and filetype.min.js are necessary in the order listed for advanced mime type parsing and more correct 20 preview. This is a feature available since v5.5.0 and is needed if you want to ensure file mime type is parsed 21 correctly even if the local file's extension is named incorrectly. This will ensure more correct preview of the 22 selected file (note: this will involve a small processing overhead in scanning of file contents locally). If you 23 do not load these scripts then the mime type parsing will largely be derived using the extension in the filename 24 and some basic file content parsing signatures. --> 25<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/plugins/buffer.min.js" type="text/javascript"></script> 26<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/plugins/filetype.min.js" type="text/javascript"></script> 27 28<!-- piexif.min.js is needed for auto orienting image files OR when restoring exif data in resized images and when you 29 wish to resize images before upload. This must be loaded before fileinput.min.js --> 30<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/plugins/piexif.min.js" type="text/javascript"></script> 31 32<!-- sortable.min.js is only needed if you wish to sort / rearrange files in initial preview. 33 This must be loaded before fileinput.min.js --> 34<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/plugins/sortable.min.js" type="text/javascript"></script> 35 36<!-- bootstrap.bundle.min.js below is needed if you wish to zoom and preview file content in a detail modal 37 dialog. bootstrap 5.x or 4.x is supported. You can also use the bootstrap js 3.3.x versions. --> 38<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script> 39 40<!-- the main fileinput plugin script JS file --> 41<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/fileinput.min.js"></script> 42 43<!-- following theme script is needed to use the Font Awesome 5.x theme (`fas`). Uncomment if needed. --> 44<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/themes/fas/theme.min.js"></script --> 45 46<!-- optionally if you need translation for your language then include the locale file as mentioned below (replace LANG.js with your language locale) --> 47<script src="https://cdn.jsdelivr.net/gh/kartik-v/bootstrap-fileinput@5.5.4/js/locales/LANG.js"></script>
With v5.2.1, the plugin is able to automatically detect the bootstrap library version and deliver the relevant bootstrap specific functionality (if you have loaded the bootstrap.min.js before fileinput.min.js). In case of any issues - you can explicitly set the bootstrap version by setting the following variable before the plugin initialization script.
1// set this before initializing the fileinput plugin 2$.fn.fileinputBsVersion = '3.4.1'; // for example if using bootstrap css 3.4.1 version
If you noticed, you need to load the jquery.min.js
and bootstrap.min.css
in addition to the fileinput.min.css
and fileinput.min.js
. The theme file themes/fa/theme.js
can be optionally included for the font awesome icons styling. The locale file <lang>.js
can be optionally included for translating for your language if needed.
Optional Dependent Plugins
- The
piexif.min.js
file is the source for the Piexifjs plugin by hMatoba. It is required to be loaded beforefileinput.min.js
if you wish to use the image resize feature of the bootstrap-fileinput plugin. - The
sortable.min.js
file is the source for the Sortable plugin by rubaxa. It is required to be loaded beforefileinput.min.js
if you wish to sort the thumbnails in the initial preview.
For ease of access, the sources for the above plugins are included in the js/plugins
folder of this project repository.
Step 2: Initialize the plugin on your page. For example,
1// HTML markup 2<input id="input-id" name="file-data" type="file"> 3 4<script> 5$(document).ready(function() { 6 // initialize with defaults 7 $("#input-id").fileinput(); 8 9 // with plugin options 10 $("#input-id").fileinput({'uploadUrl': '/path/to/your-upload-api', 'previewFileType': 'any'}); 11}); 12</script>
The #input-id
is the identifier for the input (e.g. type = file
) on your page, which is hidden automatically by the plugin.
Alternatively, you can directly call the plugin options by setting data attributes to your input field. To auto initialize the plugin with just HTML markup - add the CSS class file
to your file input markup element.
1<input id="input-id" type="file" class="file" data-preview-file-type="text" >
NOTE: When initializing the plugin via javascript (as mentioned earlier), do not add the CSS class file
to the input markup (else you would get an erronaeous / inconsistent output).
Contributors
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
License
bootstrap-fileinput is released under the BSD-3-Clause License. See the bundled LICENSE.md
for details.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
5 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
4
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to bootstrap-fileinput
@types/bootstrap-fileinput
TypeScript definitions for bootstrap-fileinput
@super-abp/bootstrap-fileinput
bootstrap-fileinput-npm
An npm friendly version of enhanced HTML 5 file input for Bootstrap 3.x with file preview, multiple selection, ajax uploads, and more features.
@backstrap/bootstrap-fileinput
An enhanced HTML 5 file input for Bootstrap 3.x with file preview, multiple selection, ajax uploads, and more features.