Limiting options in file_upload


#1

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


#2

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


#3

perfect,
thank you.

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

dorian


#4

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

thanks again