Skip to content

Instantly share code, notes, and snippets.

@melvinstanly
Last active February 8, 2019 09:54
Show Gist options
  • Save melvinstanly/cead91b21b9ff955a5e064cad29362d5 to your computer and use it in GitHub Desktop.
Save melvinstanly/cead91b21b9ff955a5e064cad29362d5 to your computer and use it in GitHub Desktop.
File Preview Before Upload jQuery
function readURL(input){
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
//e.target.result ->contain image url in encoded form
//Do action with e.target.result here. Dont place outside onload function. won't work
};
reader.readAsDataURL(input.files[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment