0.2.0 • Published 7 years ago
simple-upload-preview v0.2.0
Simple upload preview
A small package to preview image before the real upload.
Usage
Javascript Vanilla (pure javascript)
var upload = require('simple-upload-preview');
const file = document.querySelector('input[type="file"]'); // <input type="file" />
var image = document.querySelector('#blah'); // <img src="#" id="blah" />
file.addEventListener('change', upload.preview({
element: image
}, function(err, image) {
// image variable is the image element with the file from input sorced.
}));
Jquery
Download this repository or use npm / yarn
to download it.
<script src="node_modules/simple-upload-preview/browser/simple-upload.js"></script>
var image = $('#blah') // <img id="blah" />
$('input[type="file"]').preview({element: image}, function(error, image) {
// Do whatever you want with the `image` element
});
Installing
npm install simple-upload-preview
yarn install simple-upload-preview
Or download it from this repository
License
MIT © Rafael Acioly