Created
April 19, 2016 13:57
-
-
Save bogvsdev/ad1a986b5cfc84d27f1d716787092273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('[name="image"]').on('change',function(evt){ | |
if (!window.File && !window.FileReader && !window.FileList && !window.Blob) | |
return false; | |
var file = evt.target.files[0]; // FileList object | |
// Only process image files. | |
if (!file.type.match('image.*')) { | |
return; | |
} | |
var reader = new FileReader(); | |
// Read in the image file as a data URL. | |
reader.readAsDataURL(file); | |
// Closure to capture the file information. | |
reader.onload = (function(theFile) { | |
return function(e) { | |
$('.preview').attr('src', e.target.result); | |
}; | |
})(file); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment