# Limiting options in file\_upload

**URL:** <https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217>\
**Category:** Rails\
**Created:** [April 25, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217 "2006-04-25T20:25:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 25, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217/1 "2006-04-25T20:25:18Z")

</div>

Does anyone know if it’s possible to set constraints to the size & type  
of file that file\_column will accept?

I’d like to limit to image files of less than 2MB.

If this isn’t possible with file\_column, is there a graceful way of  
getting the controller to handle it?

thanks

dorian

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 26, 2006, 1:41am UTC](https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217/2 "2006-04-26T01:41:37Z")

</div>

validates\_file\_format\_of :name, :in =\> [“gif”, “jpg”, “png”]  
validates\_filesize\_of :field, :in =\> 0…2.megabytes

Gokhan  
[www.sylow.net](http://www.sylow.net)

dorian mcfarland wrote:

> Does anyone know if it’s possible to set constraints to the size & type  
> of file that file\_column will accept?
> 
> I’d like to limit to image files of less than 2MB.
> 
> If this isn’t possible with file\_column, is there a graceful way of  
> getting the controller to handle it?
> 
> thanks
> 
> dorian

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 26, 2006, 2:12am UTC](https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217/3 "2006-04-26T02:12:17Z")

</div>

perfect,  
thank you.

they aren’t in the API are they?  
I did look, honest.

dorian

---

<div class="post-metadata">

**Author:** ![tachekent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7993a0/32.png) [@tachekent](https://www.ruby-forum.com/u/tachekent)\
**Post date:** [April 26, 2006, 2:18am UTC](https://www.ruby-forum.com/t/limiting-options-in-file-upload/94217/4 "2006-04-26T02:18:28Z")

</div>

aah, ok, I just found the validations file in the plugin.  
I’ll look harder next time.

thanks again
