# How to Upload Image through RoR?

**URL:** <https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885>\
**Category:** Rails\
**Created:** [April 5, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885 "2006-04-05T14:40:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/1 "2006-04-05T14:40:55Z")

</div>

Hi,

# I have one form , in which I am using file\_field teg for input image file as follows.

# \<%= file\_field(“store”, “picture”) %\>

# Tha Actual fileld name of my Image field in Database is “store\_photo” with datatype LargeBLOB. & Inside my Store Model I have specified “def picture” as follows:-

# def picture=(picture\_field) self.store\_photo = picture\_field.read end

# Now When I am trying to Uplaod file by submitting form I am getting error like:-

# undefined method `read’ for “logo.gif”:String

Why I am getting this error? PLease tell me how to upload file into my  
database from a form & also if later I want to retrieve that image from  
database & display it on page how to do it?

Thanx.  
Prash

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 2:54pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/2 "2006-04-05T14:54:46Z")

</div>

Prashant T. wrote:

> Why I am getting this error? PLease tell me how to upload file into my  
> database from a form & also if later I want to retrieve that image from  
> database & display it on page how to do it?

Hi Prashant,

I’m sorry to be the first to do this, but I’m calling Help Vampire. \<  
[slash7 with Amy Hoy » Blog Archive » Help Vampires: A Spotter’s Guide](http://slash7.com/pages/vampires) \>

Have you looked at the documentation for file\_field ? It looks like  
what you think is the object is actually just the filename. Perhaps  
file\_field documentation can help you diagnose this problem.

You might also consider whether any changes need to be made to the form  
itself to facilitate a multiple part submission, file data and params.

A.

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/3 "2006-04-05T14:58:43Z")

</div>

Take a look at file\_column

Should do what you want

[http://wiki.rubyonrails.org/rails/pages/File+Column+Plugin](http://wiki.rubyonrails.org/rails/pages/File+Column+Plugin)

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/4 "2006-04-05T15:11:12Z")

</div>

Charlie B. wrote:

> This is exactly why the “Help Vampire” Post pissed me off so much. It’s  
> a stupid phrase and should never be used. That post will do more damage  
> to the community than 1 million “bad” questions.

You may be entirely correct. I hovered a while before sending, not at  
all sure whether to do it or not. Apologies if it offended anyone, but  
I feel the rest of the mail stands.

A.

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/5 "2006-04-05T15:01:48Z")

</div>

This is exactly why the “Help Vampire” Post pissed me off so much. It’s  
a stupid phrase and should never be used. That post will do more damage  
to the community than 1 million “bad” questions.

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/6 "2006-04-05T15:26:56Z")

</div>

Alan F. wrote:

> Charlie B. wrote:
> 
> > This is exactly why the “Help Vampire” Post pissed me off so much. It’s  
> > a stupid phrase and should never be used. That post will do more damage  
> > to the community than 1 million “bad” questions.
> 
> You may be entirely correct. I hovered a while before sending, not at  
> all sure whether to do it or not. Apologies if it offended anyone, but  
> I feel the rest of the mail stands.
> 
> A.

And FWIW, I agree it’s a stupid name for a very real thing.

A.

---

<div class="post-metadata">

**Author:** ![tiwaripk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ab992/32.png) [@tiwaripk](https://www.ruby-forum.com/u/tiwaripk)\
**Post date:** [April 5, 2006, 3:54pm UTC](https://www.ruby-forum.com/t/how-to-upload-image-through-ror/56885/7 "2006-04-05T15:54:31Z")

</div>

I agree with the principle, and I agree that it is real. As a reforming  
.NET  
user, I can attest to the pitiful state of many of the various  
communities  
because of this very real problem. Nothing is more frustrating than a  
list  
being overwhelmed with questions from those who won’t take the time to  
do a  
tiny bit of research before asking someone else to do it for them.

A community is about give AND take. If you take too much, people ignore  
you,  
and if everyone only takes, then the community disintegrates.

Matt
