Created
August 28, 2012 03:15
-
-
Save niuage/3494620 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
# extracted from http://www.html5rocks.com/en/tutorials/file/dndfiles/ | |
handleFileSelect = (event) -> | |
files = event.target.files | |
for file in files | |
continue if !file.type.match('image.*') | |
reader = new FileReader | |
reader.onload = displayImage | |
reader.readAsDataURL(file); | |
displayImage = (event) -> | |
$('<img/>').attr('src', event.target.result).appendTo 'body' | |
$ -> | |
$('#file-field').change handleFileSelect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment