Skip to content
Simple library for previewing files
JavaScript
Find file
Latest commit 60667ab @shvelo Update README.md
Failed to load latest commit information.
LICENSE Create LICENSE
README.md Update README.md
bower.json Initial commit
preview.js Preview.js it

README.md

Preview.js

Simple library for previewing selected files

Preview.js lets you preview files before uploading, just by adding to data- attributes to the file input.

Downloading

Using bower:

bower install preview.js

Or download the latest version manually from releases

Usage

Include preview.js on your page:

<script src="preview.js"></script>

Create a preview element (img, video or audio):

<img id="preview">

Add attributes to your input element:

<input id="fileinput" type="file" data-preview="#preview">

You can also use it manually from Javascript:

preview("#fileinput", { target: "#preview" });

Reference

data-preview: selector for the img,video or audio element which will contain the preview.

preview(source, options)
source: The file input element (<input type=file), can either be a selector(string), or an Element (can be obtained via document.querySelector() or document.getElementById())

options: The options object, currently supported options are:

  • target: selector for the img,video or audio element which will contain the preview.
Something went wrong with that request. Please try again.