A websocket file uploader with progressbar module.
You can use Rails or Sinatra and so on, especially this contains rails generator.
$ gem install nyoibo
Put this line in your Gemfile:
gem 'nyoibo'
Then bundle:
$ bundle install
$ rails g nyoibo:install
<%= ws_form_for(@post) do |f| %> file: <%= f.file_field :photo, :size => 40 %><br> comment: <%= f.text_field :comment, :size => 40 %><br> <%= f.submit 'upload' %> <% end %>
class SomeController < ApplicationController before_upload "/" do |params| if params["confirm"] == false return false # Not to start uploading if return false. end end after_upload "/" do |params, binary| File.open("/tmp/#{params['filename']}", "wb:binary") do |f| f.write(binary) end end end
See test/example.rb
Message me on Github (yalab) or Twitter (@yalab)
MIT-LICENSE
Copyright © 2011 Atsushi Yoshida(yalab).