Image Upload Preview Plugin With jQuery And Bootstrap - img-upload

File Size: 17 KB
Views Total: 83411
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Image Upload Preview Plugin With jQuery And Bootstrap - img-upload

img-upload is a tiny jQuery plugin that allows you to upload local or remote image files (JPG, PNG and GIF) with live preview, styling with Twitter Bootstrap.

How to use it:

1. Load Bootstrap's stylesheet and the img-upload.css in the head section of the document.

<link rel="stylesheet" href="bootstrap.min.css">
<link href="css/bootstrap-imgupload.css" rel="stylesheet">

2. Build the html structure for the image uploader ui with a preview area.

  <div class="form-group">
    <div class="imgupload panel panel-default">
      <div class="panel-heading clearfix">
        <h3 class="panel-title pull-left">Upload image</h3>
        <div class="btn-group pull-right">
          <button type="button" class="btn btn-default active">File</button>
          <button type="button" class="btn btn-default">URL</button>
      <div class="file-tab panel-body">
          <button type="button" class="btn btn-default btn-file">
          <input type="file" name="file-input">
          <button type="button" class="btn btn-default">Remove</button>
      <div class="url-tab panel-body">
        <div class="input-group">
          <input type="text" class="form-control" placeholder="Image URL">
          <div class="input-group-btn">
            <button type="button" class="btn btn-default">Submit</button>
        <input type="hidden" name="url-input">

3. Load both jQuery library and the jQuery img-upload plugin's script at the end of the document.

<script src="//"></script>
<script src="js/bootstrap-imgupload.js"></script>

4. Call the imgUpload() function to active the plugin.


5. Available plugin options.

  allowedFormats: [ "jpg", "jpeg", "png", "gif" ],
  previewWidth: 250,
  previewHeight: 250,
  maxFileSizeKb: 2048

Change log:


  • Fixed browse button text after cancelling change file dialog.



  • Fixed bug causing "browse" button not to work in Firefox and Internet Explorer.
  • URL is now checked before submitting (do nothing if empty).
  • Alerts are now displayed above instead of below.
  • Improved clarity of some error messages.
  • Image thumbnail is now displayed as a Bootstrap thumbnail.


  • Changed CSS to K&R formatting style.


  • Fixed a bug causing the submit button to persist after an error uploading from URL.

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