Customizable File Input Button With jQuery - fileinput.js

File Size: 7.91 KB
Views Total: 4008
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Customizable File Input Button With jQuery - fileinput.js

The jQuery fileinput.js plugin replaces the regular file input field with a customizable Browse button which enables the user to browse and select file(s) from local.

To clear the file input, just click the 'Clear' button displayed at the end of the selected file(s).

Easy to integrate with Bootstrap 4/3 framework and you can also create your own styles in the CSS.

How to use it:

1. Add jQuery library and the jQuery fileinput.js plugin's files to the page.

<link href="fileinput.css" rel="stylesheet">
<script src="" 
<script src="fileinput.js"></script>

2. Call the function on the file input:

<input type="file" name="file">



3. This will convert the regular file input into...

<span class="fileinput-wrapper file-selected">
  <span class="fileinput btn btn-default">
    <input type="file" name="file">
  <span class="fileinput-name">
    selected file here
    <button type="button" class="fileinput-clear close">×</button>

4. Apply your own styles to the file input button.

.btn-default {
  /* styles here */

.fileinput-name {
  /* styles here */

5. The plugin also supports multiple file input:

<input type="file" name="file" multiple>
  multipleText: '{0} files',
  showMultipleNames: true

6. More configuration options.


  // text for file select button
  title: 'Browse...',
  // class of file select button
  buttonClass: 'btn btn-default',

  // class after selected
  selectedClass: 'file-selected',

  // html of clear button
  clearButton: '<button type="button" class="fileinput-clear close">&times;</button>'

7. Trigger a function after selection.


  complete: function() {
    // $(this) is input[type="file"]


8. You can also config the file input via data attributes in case you have multiple file inputs on the page.

<input type="file" name="file"

This awesome jQuery plugin is developed by alexantr. For more Advanced Usages, please check the demo page or visit the official website.