New Post has been published on Html Use
New Post has been published on http://www.htmluse.com/html5-bootstrap-fileinput-plugin/
Html5 Bootstrap FileInput Plugin
An enhanced HTML 5 file input for Bootstrap 3.x with file preview for images and text, multiple selection, and more. This plugin is inspired by this blog article and Jasny’s File Input plugin. The plugin enhances these concepts and simplifies the widget initialization with simple HTML markup on a file input. It also offers support for multiple file preview and previewing both images and text types.
The plugin will convert a simple HTML file input to an advanced file picker control. Will help fallback to a normal HTML file input for browsers not supporting JQuery or Javascript.
The file input consists of the following three sections with options and templates to control the display:
file caption section: to display a brief information of the file(s) selected
file action buttons section: to browse, remove, and upload files.
file preview section: to display the selected files on client for preview (supports images and text file types). Other file types will be displayed as normal thumbnails.
The plugin automatically converts an input with type = file to an advanced file picker input if you set its class = file. All options to the input can be passed as HTML5 data attributes.
Ability to select and preview multiple files. Uses HTML 5 File reader API to read and preview files. Displays the progress of files being being loaded onto the preview zone, in case many files are chosen.
Offers predefined templates and CSS classes which can be changed to style your file-input display as per your needs.
With v1.5.0, you can now configure the plugin to show an initial preview of images/files with initial caption (more useful for record update scenarios). Refer the initialPreview and initialCaption properties in the plugin options section for configuring this.
Option to show/hide any or all of the following:
Customise the location of the target container elements to display the entire plugin, the caption container, the caption text, the preview container, preview image, and preview status.
For text file previews, autowrap the text to the thumbnail width, and show a wrap indicator link to display complete text on hover. You can customize the wrap indicator (which defaults to …).
Customise the messages for preview, progress, and files selected.
Upload action defaults to form submit. Supports an upload route/server action parameter for custom ajax based upload.
Triggers JQuery events for advanced development. Events currently available are filereset and fileclear.
Disabled and readonly file input support.
Size of the entire plugin is about 5KB if gzipped. The minified assets are less than 12KB (about 10KB for the minified JS and 2KB for the minified CSS).
Step 1: Load the following assets in your header.
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"> <link href="path/to/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="path/to/js/fileinput.min.js" type="text/javascript"></script>
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.
Step 2: Initialize the plugin on your page. For example,
// initialize with defaults $("#input-id").fileinput(); // with plugin options $("#input-id").fileinput('showUpload':false, 'previewFileType':'any');
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.
<input id="input-id" type="file" class="file" data-preview-file-type="text" >