Custom File Input Plugin For Bootstrap 2/3/4

File Size: 7.55 KB
Views Total: 3181
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Custom File Input Plugin For Bootstrap 2/3/4

This is a cross-browser jQuery plugin for Bootstrap that replaces the native browser file input to choose one or more files in an elegant way. Supports Bootstrap 3, Bootstrap 4 and even Bootstrap 2. Licensed under the Apache License, Version 2.0.

How to use it:

1. Import the necessary jQuery and Bootstrap.

<link rel="stylesheet" 
      href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
      integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
      crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" 
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
        crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
        integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
        crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
        integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
        crossorigin="anonymous"></script>

2. Load the Bootstrap File Upload plugin's files.

<link href="dist/css/file-upload.css" rel="stylesheet">
<script src="dist/js/file-upload.js"></script>

3. Wrap your file input into a label element.

<label class="file-upload btn btn-primary">
  Browse for file ... <input type="file" />
</label>

4. Call the main function file_upload() on the file input field and done.

$(document).ready(function() {
  $('.file-upload').file_upload();
});

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