# Store file into mysql using ruby on rails

**URL:** <https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831>\
**Category:** Rails\
**Created:** [July 19, 2010, 3:06pm UTC](https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831 "2010-07-19T15:06:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prabhat4ever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecc23a/32.png) [@prabhat4ever](https://www.ruby-forum.com/u/prabhat4ever)\
**Post date:** [July 19, 2010, 3:06pm UTC](https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831/1 "2010-07-19T15:06:04Z")

</div>

Hi plz tell me how to upload a file into mysql table in Ruby On  
Rails … ?  
also tell me how to read bytes from a file & stores in a variable in  
ruby …

thanks 🙂

---

<div class="post-metadata">

**Author:** ![prabhat4ever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecc23a/32.png) [@prabhat4ever](https://www.ruby-forum.com/u/prabhat4ever)\
**Post date:** [July 19, 2010, 3:22pm UTC](https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831/2 "2010-07-19T15:22:28Z")

</div>

On Mon, Jul 19, 2010 at 9:27 AM, Prabhat T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi plz tell me how to upload a file into mysql table in Ruby On  
> Rails … ?  
> also tell me how to read bytes from a file & stores in a variable in  
> ruby …

Have you googled something about this? What you didn’t understand?  
What you couldn’t find?  
Please, don’t ask others to do your job.

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![prabhat4ever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecc23a/32.png) [@prabhat4ever](https://www.ruby-forum.com/u/prabhat4ever)\
**Post date:** [July 19, 2010, 3:35pm UTC](https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831/3 "2010-07-19T15:35:21Z")

</div>

1. Look for the file upload helper for rails — google this and you  
should  
have a start, plenty of tutorials.

2. The one thing is when you create your model (this is only for mysql)  
is  
that if your text files are of any large size (I think more than ~64000  
chars??), you need to user the longtext datatype in mysql otherwise your  
files will get truncated.

---

<div class="post-metadata">

**Author:** ![prabhat4ever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecc23a/32.png) [@prabhat4ever](https://www.ruby-forum.com/u/prabhat4ever)\
**Post date:** [July 19, 2010, 3:35pm UTC](https://www.ruby-forum.com/t/store-file-into-mysql-using-ruby-on-rails/191831/4 "2010-07-19T15:35:21Z")

</div>

Hey bro thanks for ur reply … and plz don’t scold me dude … [:P]  
well i have done it … actually i got confused at a point which was  
base less he he he … !

have great days ahead … buddy tkcr … !
