[html-formfu] File upload and constraints / validators

Carl Franks fireartist at gmail.com
Thu Jan 17 15:58:52 GMT 2008


On 08/01/2008, Tobias Henoeckl <hoeni-formfu at sisyphus.de> wrote:
> Hi there,
>
> I'm building a form containing a file upload field with the FormFu
> Catalyst controller.
>
> Now I need to check the file size so I can keep users from uploading
> zero-sized files.
> I tried to build a custom constraint or validator to check for that, but
> can't see a way provided to access the file or its attributes (usually
> in Catalyst via $c->req->upload('fieldname') within a constrain() or
> validate() method.
>
>
> Any ideas how to workaround this? How can I trigger an error for the
> upload field in the Catalyst controller (which wouldn't very very
> elegant though)?
>
>
> Shouldn't basic checking of uploaded Files be realizeable in a Validator
> or Constraint, e.g. type checking, virus checking, etc? That could offer
> a great code reusability...

I've fixed the current constraints (most importantly, 'Required') to
ensure they can cope with file uploads.
I'll have a look now at some generic constraints to enforce man/min file sizes.

Cheers,
Carl



More information about the HTML-FormFu mailing list