On Wed, Aug 11, 2010 at 01:08:47PM +0100, Tomas Doran wrote: | | On 10 Aug 2010, at 19:59, Shlomi Fish wrote: | >I did not get any reply for this on IRC so I'm asking here. | | I believe you did later get a reply on irc. | | Could you share with the rest of the class for archival purposes?
I had a project at work like this recently. I learned a lot from this wiki entry: http://wiki.catalystframework.org/wiki/wikicookbook/controllerwithfileupload If you have a form field like this: has_field 'file' => ( type => 'Upload', max_size => '5242880', id => 'photo_file_input', required => 1, ); You can process your form like this in the controller, redefining the file param: if ( lc $c->req->method eq "post" ) { $c->req->params->{file} = $c->req->upload('file'); my $new_photo = $c->stash->{photo_rs}->new_result( { author => $c->user->id } ); $form->process( item => $new_photo, params => $c->req->params, ); $c->stash( fillinform => $form->fif ); return unless $form->validated; $c->res->redirect( $c->uri_for("/photos/gallery") ); } But then you have a Catalyst::Request::Upload object in your form field. So, you have to switch it back after file manipulation, but before saving (update_model) in the validate method: method validate { my $upload = $self->field('file')->value; $self->process_image( $upload ); $self->field('file')->value( $self->field('file')->value->filename ); } That's one way to do it. We have this running pretty well at work. Amiri _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
