Skip to content

Instantly share code, notes, and snippets.

@midu
Created August 28, 2012 03:13
Show Gist options
  • Select an option

  • Save midu/3494614 to your computer and use it in GitHub Desktop.

Select an option

Save midu/3494614 to your computer and use it in GitHub Desktop.
display
# 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