Skip to content

Instantly share code, notes, and snippets.

@jackinf
Created July 31, 2014 12:35
Show Gist options
  • Save jackinf/b9713c892ef42fffcac8 to your computer and use it in GitHub Desktop.
Save jackinf/b9713c892ef42fffcac8 to your computer and use it in GitHub Desktop.
[HTML] Check, if color CSS is valid
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});
Source:
http://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment