[Catalyst] Where is the form field lost?

Octavian Rasnita orasnita at gmail.com
Sun Jan 24 16:31:26 GMT 2010

Hi Bill,

From: "Bill Moseley" <moseley at hank.org>
> On Sun, Jan 24, 2010 at 7:03 AM, Octavian Rasnita 
> <orasnita at gmail.com>wrote:
> I need to know if the form didn't have a file upload field, or if it had 
> it
> but no file was uploaded.
> Give your upload field(s) a name like "upload_1"  and then see if it 
> exists
> in uploads.

I gave it the name "file", but if the file is not uploaded, it doesn't 
appear in uploads(). (I hope "file" is OK as a name, no?)

> Can you give me a hint where I should look for finding where the empty 
> file
>> upload field is skipped if it is empty?
> That's how HTTP::Body works.   If there's a filename, which there is with
> upload fields, but the file name is empty, then it's skipped.

Aha, so I should look better in HTTP::Body.
Is there a reason it does that? (Leaves alone all other empty form fields 
but deletes the empty file upload fields?)

>        if ( exists $part->{filename} ) {
>            if ( $part->{filename} ne "" ) {
>                $part->{fh}->close if defined $part->{fh};
>                delete @{$part}{qw[ data done fh ]};
>                $self->upload( $part->{name}, $part );
>            }
>        }
> BTW -- I think that delete of "fh" should not happen (and the temp file
> should be set to unlink on destroy).  Otherwise you can end up with 
> orphaned
> temp files.

And I think it should also returned the empty file upload field as an empty 
upload field, and not delete it at all.
I think this change cannot cause errors in other places.


More information about the Catalyst mailing list