# Uploading files and writing them to server?

**URL:** <https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243>\
**Category:** Rails\
**Created:** [March 29, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243 "2006-03-29T19:36:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243/1 "2006-03-29T19:36:24Z")

</div>

Where should I look for information on how to use Rails and Ruby to  
accept the upload of a file and then to save that file to the file  
system of my server?

I’m reading the “Uploading a file” section of Agile Web Dev with Rails,  
but it’s geared toward saving the file in the database.

Any advice?

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243/2 "2006-03-29T19:57:19Z")

</div>

If I remember correctly I used the AWDR example for the front-end and  
did  
the back-end piece after reading the file handling info from the  
Programming  
Ruby book - roughly in this section.

[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut\_io.html](http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_io.html)

If you haven’t tried the Ruby Sidebar, yet. It’s a great resource.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 8:00pm UTC](https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243/3 "2006-03-29T20:00:37Z")

</div>

Google for the file\_column plugin. It handles many of the minutae like  
figuring out where in the filesystem to store the files, handling the  
form field gracefully when it comes to updating the database record that  
references it, etc., all through a one-line declaration in the model and  
a string (varchar) field for the filename. And if they’re image files,  
it’s got hooks into RMagick, ImageMagick, etc. for creating and caching  
resized and otherwise processed versions of the image.

Not perfect but applicable to most situations and a whole lot easier  
than reinventing the wheel.

Jeff C.man wrote:

> Where should I look for information on how to use Rails and Ruby to  
> accept the upload of a file and then to save that file to the file  
> system of my server?
> 
> I’m reading the “Uploading a file” section of Agile Web Dev with Rails,  
> but it’s geared toward saving the file in the database.
> 
> Any advice?
> 
> Thanks,  
> Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 29, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/uploading-files-and-writing-them-to-server/56243/4 "2006-03-29T20:18:04Z")

</div>

Thanks, Steve, that is exactly what I’m looking for!

I’ve just started playing with RMagick, as well. I have a model named  
Image, which seems to be causing a namespace conflict. Is there a way I  
can resolve that without changing my model?

Jeff

Steve K. wrote:

> Google for the file\_column plugin. It handles many of the minutae like  
> figuring out where in the filesystem to store the files, handling the  
> form field gracefully when it comes to updating the database record that  
> references it, etc., all through a one-line declaration in the model and  
> a string (varchar) field for the filename. And if they’re image files,  
> it’s got hooks into RMagick, ImageMagick, etc. for creating and caching  
> resized and otherwise processed versions of the image.
> 
> Not perfect but applicable to most situations and a whole lot easier  
> than reinventing the wheel.
> 
> Jeff C.man wrote:
> 
> > Where should I look for information on how to use Rails and Ruby to  
> > accept the upload of a file and then to save that file to the file  
> > system of my server?
> > 
> > I’m reading the “Uploading a file” section of Agile Web Dev with Rails,  
> > but it’s geared toward saving the file in the database.
> > 
> > Any advice?
> > 
> > Thanks,  
> > Jeff
