Find file
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (52 sloc) 2.6 KB


This plugin will help you to embed swf upload into your project Installation:

script/plugin install git://
#script/generate easy_swf_upload is called for you automatically


In your application.html.erb include javascripts:

<%= javascript_include_tag :defaults, :swf_upload %>

Important: Plugin doesn't works without prototype javascript library

Then, use this helper to embed swf upload to your application:

<%= swf_upload_area "Upload images", :url => upload_image_block_path,
        :filetypes => "*.jpg; *.gif",
        :button_style => "font-family: Arial, sans-serif; font-size: 14pt; font-weight:bold;" %>

Advanced options: single_file: true – allow upload only 1 file file_size_limit: “500 MB” – set maximum uploadable file size to 500 MB, default - 40 MB

In your controller:

class PagesController < ApplicationController

# If your rails version < 2.3.0, go this way

  session :cookie_only => false, :only => :upload_image_block # this is very important, don't forget to set it to false

  def upload_image_block
    @image_block = => swf_upload_data) # here you can use your favourite plugin to work with attachments

    # use RJS here
    render :update do |page|
      page['blocks'].insert("<div><img src="" /></div>")

Also, you need to customize uploading area, i used this css:

<style type="text/css">
  ul.uploadContainer { padding: 10px; }
  ul.uploadContainer li { font-size: 14px; position: relative; height: 22px; }
  ul.uploadContainer li h6 { font-size: 14px; }
  ul.uploadContainer li { width: 100%; height: 4px; }
  ul.uploadContainer li div.progress { position: absolute; top: 17px; height: 4px; background: #63b534; }

Or if you use LESS or css_dryer:

ul.uploadContainer {
  padding: 10px;

  li {
    font-size: 14px; position: relative; height: 22px;

    h6 { font-size: 14px; } { width: 100%; height: 4px; }
    div.progress { position: absolute; top: 17px; height: 4px; background: #63b534; }

Uploading file template:

<li id="#{id}"><h6>#{title}</h6><div class="bar"><div class="progress" style="width:0"></div></div></li>



Jason Murad, Joris Trooster, Ivan Kuchin, Igor Gladkoborodov

Copyright © 2008—2010 Mikhail Tabunov, released under the MIT license