• Stars
    star
    5,356
  • Rank 7,709 (Top 0.2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 10 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.

Krajee Logo
bootstrap-fileinput
Donate       kartikv

Financial Contributors on Open Collective Latest Stable Version License Packagist Downloads Monthly Downloads

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.

Krajee Default Theme

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.

Krajee Explorer Theme

Documentation and Demo

View the plugin documentation and plugin demos at Krajee JQuery plugins.

Pre-requisites

  1. Bootstrap 5.x or 4.x, or 3.x
  2. Latest JQuery
  3. 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.
  4. 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 plain bootstrap 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.

<!-- bootstrap 5.x or 4.x is supported. You can also use the bootstrap css 3.3.x versions -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" crossorigin="anonymous">

<!-- default icons used in the plugin are from Bootstrap 5.x icon library (which can be enabled by loading CSS below) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" crossorigin="anonymous">

<!-- alternatively you can use the font awesome icon library if using with `fas` theme (or Bootstrap 4.x) by uncommenting below. -->
<!-- link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" crossorigin="anonymous" -->

<!-- the fileinput plugin styling CSS file -->
<link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />

<!-- if using RTL (Right-To-Left) orientation, load the RTL CSS file after fileinput.css by uncommenting below -->
<!-- link href="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/css/fileinput-rtl.min.css" media="all" rel="stylesheet" type="text/css" /-->

<!-- the jQuery Library -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>

<!-- buffer.min.js and filetype.min.js are necessary in the order listed for advanced mime type parsing and more correct
     preview. This is a feature available since v5.5.0 and is needed if you want to ensure file mime type is parsed 
     correctly even if the local file's extension is named incorrectly. This will ensure more correct preview of the
     selected file (note: this will involve a small processing overhead in scanning of file contents locally). If you 
     do not load these scripts then the mime type parsing will largely be derived using the extension in the filename
     and some basic file content parsing signatures. -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/buffer.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/filetype.min.js" type="text/javascript"></script>

<!-- piexif.min.js is needed for auto orienting image files OR when restoring exif data in resized images and when you
    wish to resize images before upload. This must be loaded before fileinput.min.js -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/piexif.min.js" type="text/javascript"></script>

<!-- sortable.min.js is only needed if you wish to sort / rearrange files in initial preview. 
    This must be loaded before fileinput.min.js -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/sortable.min.js" type="text/javascript"></script>

<!-- bootstrap.bundle.min.js below is needed if you wish to zoom and preview file content in a detail modal
    dialog. bootstrap 5.x or 4.x is supported. You can also use the bootstrap js 3.3.x versions. -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>

<!-- the main fileinput plugin script JS file -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/fileinput.min.js"></script>

<!-- following theme script is needed to use the Font Awesome 5.x theme (`fas`). Uncomment if needed. -->
<!-- script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/themes/fas/theme.min.js"></script -->

<!-- optionally if you need translation for your language then include the locale file as mentioned below (replace LANG.js with your language locale) -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/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.

// set this before initializing the fileinput plugin
$.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 before fileinput.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 before fileinput.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,

// HTML markup
<input id="input-id" name="file-data" type="file">

<script>
$(document).ready(function() {
    // initialize with defaults
    $("#input-id").fileinput();

    // with plugin options
    $("#input-id").fileinput({'uploadUrl': '/path/to/your-upload-api', 'previewFileType': 'any'});
});
</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.

<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.

More Repositories

1

bootstrap-star-rating

A simple yet powerful JQuery star rating plugin with fractional rating support.
JavaScript
1,055
star
2

yii2-widgets

Collection of useful widgets for Yii Framework 2.0
PHP
558
star
3

yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
PHP
556
star
4

yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
CSS
323
star
5

yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
PHP
229
star
6

dependent-dropdown

JQuery plugin that enables to add and control multi level dependent dropdown lists.
JavaScript
182
star
7

yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
PHP
165
star
8

yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.
CSS
162
star
9

yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
PHP
150
star
10

bootstrap-popover-x

Bootstrap popover extended with modal properties and more.
116
star
11

yii2-editable

An enhanced editable widget for Yii 2.0 that allows easy editing of displayed data with html inputs, widgets and more.
PHP
112
star
12

yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets)
PHP
112
star
13

yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)
PHP
105
star
14

bootstrap-tabs-x

Bootstrap tabs supercharged with various alignment and styling options
101
star
15

yii2-builder

Build forms (single or tabular) easily for Yii Framework 2.0.
PHP
100
star
16

bootstrap-checkbox-x

An extended checkbox plugin for bootstrap with three states and additional styles.
JavaScript
93
star
17

yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
JavaScript
92
star
18

yii2-social

A Yii2 module for embedding social plugins and widgets.
PHP
92
star
19

yii2-helpers

Collection of useful helper functions for Yii Framework 2.0
PHP
89
star
20

yii2-markdown

Advanced Markdown editing and conversion utilities for Yii Framework 2.0
PHP
89
star
21

strength-meter

A dynamic strength meter for password input validation with various configurable options.
JavaScript
88
star
22

yii2-widget-depdrop

Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets).
PHP
82
star
23

yii2-password

Useful password strength validation utilities for Yii Framework 2.0
PHP
75
star
24

yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
PHP
74
star
25

yii2-icons

Set of icon frameworks for easy use in Yii Framework 2.0
CSS
70
star
26

yii2-detail-view

Various enhancements to the Yii 2 Detail View with ability to edit data and manage styles using BS3.
PHP
70
star
27

yii2-krajee-base

Foundation classes and components used by Krajee Yii2 extensions
PHP
68
star
28

yii2-app-practical

Yii 2 Practical Project Template (based on advanced app)
PHP
67
star
29

yii2-widget-activeform

Enhanced Yii2 active-form and active-field with full bootstrap styling support (sub repo split from yii2-widgets).
PHP
63
star
30

yii2-datecontrol

Date control module allowing separation of date formats for View & Model for Yii Framework 2.0.
PHP
55
star
31

yii2-dialog

An extension that wraps bootstrap3-dialog for Yii 2.0 framework
PHP
49
star
32

yii2-widget-typeahead

Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).
JavaScript
45
star
33

yii2-widget-rating

A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)
PHP
45
star
34

php-date-formatter

A Javascript datetime formatting and manipulation library using PHP date-time formats.
JavaScript
44
star
35

yii2-sortable

Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.
JavaScript
43
star
36

yii2-widget-timepicker

Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets).
PHP
41
star
37

krajee-markdown-editor

A Boostrap styled markdown editor that offers configurable toolbar, live preview, export, fullscreen mode, and more features
JavaScript
41
star
38

mpdf

Fork of the mPDF latest DEV library (unofficial) with composer and packagist support.
PHP
40
star
39

yii2-widget-switchinput

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle switches (sub repo split from yii2-widgets)
PHP
38
star
40

yii2-widget-growl

A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)
PHP
38
star
41

yii2-widget-sidenav

An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-widgets)
PHP
36
star
42

bootstrap-fileinput-samples

Example files for the bootstrap-fileinput plugin
35
star
43

yii2-app-practical-a

Yii 2 Practical-A ProjectTemplate (based on advanced app)
PHP
34
star
44

yii2-widget-colorinput

An enhanced Yii2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)
JavaScript
32
star
45

yii2-app-practical-b

Yii 2 Practical Application Template (based on basic app)
PHP
31
star
46

yii2-tabs-x

Extended bootstrap tabbed navigation widget for Yii 2.0 with various alignment and styling options.
PHP
30
star
47

yii2-widget-alert

An extended bootstrap alert and alert block widget for Yii2 (sub repo split from yii2-widgets)
PHP
28
star
48

yii2-nav-x

Extended bootstrap Nav widget with submenu option for Yii 2.
PHP
28
star
49

yii2-widget-spinner

A widget to render animated CSS3 loading spinners with VML fallback for IE (sub repo split from yii2-widgets)
JavaScript
28
star
50

yii2-slider

A slider input with orientations, range selections and more features based on bootstrap-slider.
PHP
28
star
51

yii2-ipinfo

An IP address information display widget for Yii 2 with country flag and geo position info
PHP
27
star
52

yii2-money

An advanced money mask input for Yii 2.0 styled for Bootstrap 3
JavaScript
26
star
53

yii2-checkbox-x

Extended checkbox widget for bootstrap with three states and additional styles for Yii 2.
PHP
25
star
54

yii2-field-range

Easily manage Yii 2 ActiveField ranges (from/to) with Bootstrap 3.x / 4.x addons markup and more.
PHP
24
star
55

yii2-popover-x

Extended bootstrap popover for Yii 2.0 with modal behavior and various styling options.
PHP
23
star
56

yii2-sortable-input

An input widget based on yii2-sortable extension allowing to store/save the sort order.
PHP
23
star
57

yii2-number

A number format mask control and input for Yii2 Framework
PHP
22
star
58

yii2-editors

Yii2 editor widgets Summernote and Codemirror.
PHP
22
star
59

yii2-validators

Enhanced Yii2 model validator components / utilities for Yii2 Framework
PHP
20
star
60

yii2-widget-rangeinput

An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)
PHP
19
star
61

yii2-widget-touchspin

Yii2 wrapper for the bootstrap-touchspin spinner component (sub repo split from yii2-widgets)
JavaScript
18
star
62

yii2-widget-affix

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)
PHP
15
star
63

yii2-dropdown-x

An extended bootstrap dropdown widget for Yii 2 with submenu drilldown.
PHP
15
star
64

yii2-label-inplace

A form enhancement widget for in-field label support.
JavaScript
11
star
65

yii2-bootstrap4-dropdown

Enhanced Bootstrap 4 dropdown widget for Yii2 framework with nested submenu support.
PHP
9
star
66

yii2-word-report

Make reports in Yii2 with Microsoft Word Templates
PHP
9
star
67

yii2-report

Create reports out of MS Word templates using PHP-Reports api.
PHP
8
star
68

yii2-context-menu

Yii 2 context menu extension with Bootstrap 3 styling.
PHP
7
star
69

yii2-filesystem

File system handling utilities and components
PHP
6
star
70

yii2-mail-manager

Mailer management module with queuing and administration
PHP
6
star
71

yii2-rest-api

Yii2 Rest API Template
PHP
5
star
72

yii2-mailer

A mail management module for Yii 2.0 with ability to manage mail queues, templates, and more.
4
star
73

yii2-mxgraph

Yii2 port of the MxGraph library
3
star
74

yii2-google-docs

2
star
75

yii2-query-filter

Advanced Yii2 query filters via an easy user interface
1
star
76

kartik-v

1
star
77

yii2-bootstrap5-dropdown

Enhanced Bootstrap 5 dropdown widget for Yii2 framework with nested submenu support
PHP
1
star