Hi Bill,

From: "Bill Moseley" <mose...@hank.org>
On Sun, Jan 24, 2010 at 7:03 AM, Octavian Rasnita <orasn...@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.

Octavian


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to