views:

1309

answers:

5

How do I upload images and zip files in RoR? I am a newbie. So please help. Give me both the view and the controller code example.

Thanks in advance.

+8  A: 

Nav,

Try the paperclip plugin, you can read about it here http://www.thoughtbot.com/projects/paperclip

Beaks
A: 

One option is attachment_fu. It allows you to save your uploaded file to the filesystem, database, or Amazon S3. It also allows you to select which image processor is used, such as RMagick or Minimagick.

The link provides better code than I could here.

erik
As a side note, I prefer paperclip to attachment_fu. It is more opinionated with sensible defaults a la "The Rails Way"
erik
+3  A: 

suggest checking out the Railscast for paperclip.

+1  A: 

ImageMagick is also pretty cool

marcgg
+1  A: 

I would recommend paperclip, and the patch that allows you to store the content in the database instead of the file system

http://patshaughnessy.net/paperclip-database-storage

the link has the view and controller examples that you are looking for

Aaron Saunders