file uploading controller

how to upload a video,document and a audio (of any format) within the same controller and within the same form?

is it possible to do that?

if not then what is the solution?

how to upload a video,document and a audio (of any format) within the same controller and within the same form?

is it possible to do that?

if not then what is the solution?

If you're using Paperclip or CarrierWave, just add two separate file attributes to your base model, following the usual instructions for either. If you want to be able to attach N number of files of any format to a base model, consider the nested_form Gem by Ryan Bates, and be sure to watch his Railscast on "Complex Forms 1 & 2" to make sure you grasp what the gem is making for you.

Walter

you told to me this solution

If you're using Paperclip or CarrierWave, just add two separate file attributes to your base model, following the usual instructions for either. If you want to be able to attach N number of files of any format to a base model, consider the nested_form Gem by Ryan Bates, and be sure to watch his Railscast on "Complex Forms 1 & 2" to make sure you grasp what the gem is making for you.

but,i am the fresher please told me how to add two separate file attributes in our model? kindly give me the solution with small code?

you told to me this solution

If you're using Paperclip or CarrierWave, just add two separate file attributes to your base model, following the usual instructions for either. If you want to be able to attach N number of files of any format to a base model, consider the nested_form Gem by Ryan Bates, and be sure to watch his Railscast on "Complex Forms 1 & 2" to make sure you grasp what the gem is making for you.

but,i am the fresher please told me how to add two separate file attributes in our model? kindly give me the solution with small code?

Assuming you are using Paperclip, and you have a Foo model, and you have read the ReadMe on the Paperclip GitHub page, you would do this:

rails generate paperclip Foo image_one rails generate paperclip Foo image_two rake db:migrate

Now you have the proper bits in your database. If you are using attr_accessible in your model (please say yes) then you have to add :image_one, :image_two, to the beginning of the list of accessible attributes.

Add

has_attached_file :image_one, :styles => {} has_attached_file :image_two, :styles => {}

to your model.

In your view's form_for call, add :html => { :multipart => true } before the do, so it looks like this:

<%= form_for @foo, :html => { :multipart => true } do |f| %>

In your form body, add a field for each image:

<%= f.file_field :image_one %> <%= f.file_field :image_two %>

And you're done. Files will upload to your public/system/foos/image_[one|two]/original/ folder, off the top of my head. You can configure EVERYTHING, just read the Wiki.

Walter