Validation of file uploads

Hi,

I tried to validate a file input form field using validates_presence_of
:imagefile, which seems to always return true. How can I validate that
the user has chosen a file to upload?

thx
Robert

protected
def validate
errors.add(“imagefile”, “Must be a valid file.”) unless
imagefile.respond_to? :read
end

Haven’t tested this, try this out tho.

Vish