Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails plugins for easy embedding swf upload into your project
JavaScript Ruby
Branch: master
Pull request Compare This branch is 6 commits ahead, 25 commits behind over:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators/easy_swf_upload
lib
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

EasySwfUpload

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

First, install this plugin:
script/plugin install git://github.com/over/easy_swf_upload.git

Then, run generator:
script/generate easy_swf_upload

Example

In your application.html.erb include javascripts:

<%= javascript_include_tag :defaults, "swfupload", "swfupload_plugin" %>

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;" %>

You want to allow uploading only single file at once, you can pass :single_file => true option to swf_upload_area helper.

In your controller: 
class PagesController < ApplicationController
  session :cookie_only => false # this is very important, don't forget to set it to false
  
  def get_image_block
	@image_block = ImageBlock.new(:file => 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="http://domain.com" /></div>")
    end
  end
end


Also, you need to customize uploading area, i used this css:
<style>
body {
	font-family:Arial, Helvetica, Sans-serif; font-size:12px;
}

.uploadContainer {
	margin:0; padding:0;
}
.uploadContainer li {
	list-style:none;
	margin:0; padding:0;
	padding:4px; border:#CCC; margin-bottom:10px;
	position:relative; height:22px;
    }

.uploadContainer li h6 {
	margin:0; padding:0; color:#000;
	font-size:11px; position:relative; z-index:2;
}

.uploadContainer li div.progress {
	margin:0; padding:0;
    position:absolute;
    left:0; bottom:0;
    height:5px; z-index:1; background:#003ee3;
}
</style>

Uploading file template:


<li id="file_#{id}"><div class="progress" style="width:1%"></div><h6>#{title}</h6></li>


Thanks.

Copyright (c) 2008 Mikhail Tabunov, released under the MIT license
Something went wrong with that request. Please try again.