Skip to content

Instantly share code, notes, and snippets.

@ffaerber
Created October 9, 2011 23:53
Show Gist options
  • Select an option

  • Save ffaerber/1274390 to your computer and use it in GitHub Desktop.

Select an option

Save ffaerber/1274390 to your computer and use it in GitHub Desktop.
plupload rails 3.1 coffeescript
$(document).ready ->
uploader = new plupload.Uploader
runtimes : "html5",
browse_button : 'pickfiles',
container: 'container',
max_file_size : '10mb',
url : "/media",
multipart: true,
multipart_params:
"authenticity_token" : AUTH_TOKEN
uploader.bind 'Init', (up, params) ->
$('#filelist').html "<div>Current runtime: #{params.runtime} </div>"
uploader.bind 'FilesAdded', (up, files) ->
$.each files, (i, file) ->
$('#filelist').append "<div id='#{file.id}'> #{file.name} (#{ plupload.formatSize file.size }) <b></b></div>"
uploader.bind 'UploadProgress', (up, file) ->
$("##{file.id} b").html "#{file.percent}%"
$('#uploadfiles').click (e) ->
uploader.start()
e.preventDefault()
uploader.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment