Can Perl's CGI.pm process Firefox's <input type=“file”, multiple=“”> form fields?

前端 未结 4 1402
一生所求
一生所求 2021-01-03 07:33

Firefox 3.6 introduced a [multiple attribute on regular type=\"file\" input elements]( http://hacks.mozilla.org/2009/12/multiple-file-input-in-firefox-3-6/).

I canno

4条回答
  •  执笔经年
    2021-01-03 08:12

    Yes, perl's CGI.pm can proess firefox's multiple file uploads

    Want to see? Use this shortcut:

    use Data::Dumper;
    print '
    ', $CGIo->escapeHTML( Dumper( $CGIo ) ),'
    ';

    You'll see something like:

    $VAR1 = bless( {
             '.parameters' => [
                                'filename',
                                'submit'
                              ],
             'use_tempfile' => 1,
             '.tmpfiles' => {
                              '*Fh::fh00003temp-2.txt' => {
                                                            'info' => {
                                                                        'Content-Type' => 'text/plain',
                                                                        'Content-Disposition' => 'form-data; name="filename"; filename="temp-2.txt"'
                                                                      },
                                                            'name' => bless( do{\(my $o = 'C:\\WINDOWS\\TEMP\\CGItemp52869')}, 'CGITempFile' ),
                                                            'hndl' => bless( \*{'Fh::fh00003temp-2.txt'}, 'Fh' )
                                                          },
                              '*Fh::fh00001temp-1.txt' => {
                                                            'info' => {
                                                                        'Content-Type' => 'text/plain',
                                                                        'Content-Disposition' => 'form-data; name="filename"; filename="temp-1.txt"'
                                                                      },
                                                            'name' => bless( do{\(my $o = 'C:\\WINDOWS\\TEMP\\CGItemp52775')}, 'CGITempFile' ),
                                                            'hndl' => bless( \*{'Fh::fh00001temp-1.txt'}, 'Fh' )
                                                          }
                            },
             '.charset' => 'ISO-8859-1',
             'param' => {
                          'filename' => [
                                          $VAR1->{'.tmpfiles'}{'*Fh::fh00001temp-1.txt'}{'hndl'},
                                          $VAR1->{'.tmpfiles'}{'*Fh::fh00003temp-2.txt'}{'hndl'}
                                        ],
                          'submit' => [
                                        'Process File'
                                      ]
                        },
             'escape' => 1,
             '.header_printed' => 1
           }, 'CGI' );
    

    First you call your file upload field File_Input, then you call it multiple_files, then you call it myfiles -- you have to use the same name, this important.

    Also, $lightweight_fh and @lightweight_fh are two distinct variables, you'll need

    for my $lightweight_fh ( $CGIo->upload('multiple_files') ){
        my $io_handle = $lightweight_fh->handle;
        ...
    }
    

    Also, you try to open a DIRECTORY '/hidden_deliberately/' as a file, and you don't check for errors

提交回复
热议问题