Forum: Ruby on Rails limiting options in file_upload

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dorian M. (Guest)
on 2006-04-25 22:25
(Received via mailing list)
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
Gokhan A. (Guest)
on 2006-04-26 03:41
validates_file_format_of :name, :in => ["gif", "jpg", "png"]
validates_filesize_of :field, :in => 0..2.megabytes

Gokhan
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
Dorian M. (Guest)
on 2006-04-26 04:12
(Received via mailing list)
perfect,
thank you.

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

dorian
Dorian M. (Guest)
on 2006-04-26 04:18
(Received via mailing list)
aah, ok, I just found the validations file in the plugin.
I'll look harder next time.

thanks again
This topic is locked and can not be replied to.