Or SWFUpload and attachment_fu. SWFUpload does have some caveats you
need to overcome and I should start a blog and write a post on it.
Basically it comes down to overcoming Rails 2''s security measures
without disabling them and it''s perfectly possible. There are some
posts around that deal with it, but they all have their flaws. I''ll
just post some relevant sections of my code in here so everyone at
least has a reference to go by (it should be indexed by google).
1. Make a file "swf_session.rb" in config/initializers/ with
http://pastie.org/244830
as the contents (this is a slightly modified version of the original
author code)
2. Include the following in your layout (and put the appropriate files
in the javascript/swfupload/ folder of course (swfupload_cookies will
automatically add all of your app''s cookies as POST parameters):
javascript_include_tag("swfupload/swfupload",
"swfupload/
swfupload_swfobject",
"swfupload/
swfupload_cookies",
:cache =>
"swfupload")
3. Add this in the <head> section of your layout:
<script type="text/javascript" charset="utf-8">
window._token = ''<%= form_authenticity_token
-%>'';
</script>
4. Optionally you can add this to your application.js file (to
automatically add the authenticity token to all your custom
javascript): http://pastie.org/244842
5. I use a custom javascript "class" to handle all of the uploads,
this is part of that code (you''ll need to implement all the handlers
and adapt the code to your application of course): http://pastie.org/244838
file_post_name : "document[uploaded_data]" is the name of the model
instance and field you want to post to (@document.uploaded_data),
attachment_fu automatically handles this field.
6. Expose the relevant controller actions (the ones that handle the
uploads) so the session can be passed in as a POST variable:
class DocumentsController < ApplicationController
session :cookie_only => false, :only => :create
def create
... <create new document code here>
end
end
7. Add the mime-types gem to config/environment.rb as a requirement:
config.gem "mime-types", :lib => "mime/types",
:version => ''>= 1''
8. Patch the attachment_fu plugin a little: vendor/plugins/
attachment_fu/lib/technoweenie/attachment.fu.rb: http://pastie.org/244854
This is just to make your life easier and let attachment_fu do its
magic without you having to worry about setting the content_type.
Implementing SWFUpload can be quite an adventure and you really need
to understand what''s going on, but the result is the best
"ajax"
upload you can imagine.
On 31 Jul 2008, at 16:26, Benjamin Curtis wrote:
> Try SWFUpload and PaperClip.
>
> --
> Benjamin Curtis
> http://railskits.com/ - Ready-made Rails code
> http://catchthebest.com/ - Team-powered recruiting
> http://www.bencurtis.com/ - Personal blog
>
> On Jul 29, 7:19 pm, Brandon
<bgree...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> I''m designing a website that allows users to upload documents,
>> images,
>> mp3s and videos. What is a good upload plugin that can handle all
>> these file types?
>>
>> Required:
>> * Simple integration with rmagick or other image processing plugins
>>
>> Nice to have:
>> * Progress bar
>> * Multiple file uploads
>>
>> Thanks in advance for any advice.
Best regards
Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---