Git Product home page Git Product logo

easy_swf_upload's Introduction

_This is a modified version of EasySwUpload. I added several things for my own use (like the jsProgressBarHandler 0.3.3 - by Bramus) and fixed some issues that I came across. Please have a look at the original version from ‘over’ github.com/over/easy_swf_upload which may fit your needs better._

Joris.

EasySwfUpload

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

First, install this plugin (my modified fork, or over’s original version):

script/plugin install git://github.com/trooster/easy_swf_upload.git or script/plugin install git://github.com/over/easy_swf_upload.git
#script/generate easy_swf_upload is called for you automatically

Example

In your application.html.erb include javascripts:

<%= javascript_include_tag :defaults, :swf_upload %>

Or on a specific page (assuming the prototype libraries are loaded in your application template):

<% content_for :javascript do %>

<%= javascript_include_tag :swf_upload %>

<% end %>

The Plugin does not works without the prototype javascript library.

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

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

If you want to allow uploading of only a single file, you can pass :single_file => true option to swf_upload_area helper.

If you want a file size limit use the file_size_limit option, for example :file_size_limit => “2 MB”. The default file size limit = 40 MB.

Another example with a button image, and single file upload:

<%= swf_upload_area :url => upload_image_block_path,
        :filetypes => "*.jpg; *.gif",
        :single_file => true,
        :file_size_limit => "100 MB"
        :button_image_url => "../images/XPButtonUploadText_61x22.png",
        :button_width => 61,
        :button_height => 22 %>

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 = ImageBlock.new(:file => swf_upload_data) # here you can use your favourite plugin to work with attachments

    # use RJS here
    # render :action => "upload_image_block.js.rjs"
    render :update do |page|
      page['blocks'].insert("<div><img src="http://domain.com" /></div>")
    end
  end
end

Also, you need to customize uploading area, for example:

<style>
.uploadContainer {
  margin: 0; padding: 0;
}

.uploadContainer li {
  list-style: none;
  margin: 0; padding: 0; height: 2em;
  padding: 0.4em; border: #ccc; margin-bottom: 1em;
}

.uploadContainer li h6 {
  margin: 0; padding: 0; color: #000;
  font-size: 1.1em;
}
</style>

Uploading file template:

<li id="#{id}"><h6>#{title}</h6><span id="#{id}_progress">[ Loading Progress Bar ]</span></li>

– Copyright © 2008 Mikhail Tabunov, released under the MIT license See commit history on github for changes by others

easy_swf_upload's People

Contributors

igorgladkoborodov avatar over avatar toy avatar trooster avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.