I think everybody's a little confused here.   I might be wrong but I think that you were concerned that the filename submitted at the remote client might confuse your program or might somehow be invalid at the CGI host.

So you were trying to figure out how to get a look at the filename, in order to validate it?   And that got you into wanting to use GET where you could 'see' the parameters.   Which got everybody concerned because everybody _knows_ file uploads require POST.   But then again maybe you were wanting to know _how_ to know if anything really got uploaded to your site.

Well I hadn't yet played with file uploads and need to soon, so I put together the test program following.   I used the docs for the CGI module to do this.   Using this code you can test out some of your assumptions or ideas.

#!/usr/bin/perl -w use strict; use warnings; use CGI qw/:standard/; my $q = new CGI; my $cgi_error = $q->cgi_error(); if( $cgi_error ) { print $q->header( -status => $cgi_error ), $q->start_html('Problems'), $q->h2('Request not processed'), $q->strong($cgi_error), $q->end_html(); exit(0); } my( $latest_fullpath, $latest_filepath, $latest_filename ); my( $latest_status, $latest_length, $latest_content_type ); if( $q->param() ) { $q->param('latest_fullpath', '' ); $q->param('latest_filepath', '' ); $q->param('latest_filename', '' ); $q->param('latest_length', '' ); $q->param('latest_status', '' ); $q->param('latest_content', '' ); $latest_fullpath = $q->param('filename'); $q->param('latest_fullpath', $latest_fullpath ); my( $filepath, $filename ) = ($latest_fullpath =~ /^( (?: .* [:\\\/] )? ) (.*) $/x) +; $q->param('latest_filepath', $filepath ); $q->param('latest_filename', $filename ); my $rhhdrs = $q->uploadInfo($latest_fullpath); $latest_content_type = $rhhdrs->{'Content-Type'}; $q->param('latest_content', $latest_content_type ); my $uploadfh = $q->upload('filename'); if( $uploadfh ) { while( <$uploadfh> ) { $latest_length += length $_; } # $latest_length += 42; $q->param('latest_length', $latest_length ); } elsif( $q->cgi_error ) { print $q->header( -status => $q->cgi_error ); exit(0); } else { $q->param('latest_status', 'No filehandle?' ); } } print $q->header(), $q->start_html( -title => 'Testing file uploads' ), $q->start_multipart_form({ -method => 'POST', -action => 'testingx.pl' }), $q->filefield({ -name => 'filename', }), ' &nbsp; ', $q->submit('Add'), $q->end_form(), $q->hr(), $q->textfield('latest_fullpath'), ' &nbsp; Latest Fullpath', + $q->br(), $q->textfield('latest_filepath'), ' &nbsp; Latest Filepath', + $q->br(), $q->textfield('latest_filename'), ' &nbsp; Latest Filename', + $q->br(), $q->textfield('latest_length'), ' &nbsp; Latest Length', + $q->br(), $q->textfield('latest_status'), ' &nbsp; Latest Status', + $q->br(), $q->textfield('latest_content'), ' &nbsp; Latest Content-ty +pe', $q->br(), $q->hr(), " CGI::POST_MAX is '$CGI::POST_MAX'", $q->br(), " CGI::DISABLE_UPLOADS is '$CGI::DISABLE_UPLOADS'", $q->br( +), " REQUEST_METHOD is ", $q->request_method(), $q->br(), " CONTENT_TYPE is ", $q->content_type(), $q->br(), $q->end_html();
Output for me when entering an invalid filename was: (using IE to a Linux/Apache host)
----------------------------------------------------
  farquarh.txt                   Latest Fullpath
                                 Latest Filepath
  farquarh.txt                   Latest Filename
                                 Latest Length
                                 Latest Status
  application/octet-stream       Latest Content-type

----------------------------------------------------
CGI::POST_MAX is '-1'
CGI::DISABLE_UPLOADS is '0'
REQUEST_METHOD is POST
CONTENT_TYPE is multipart/form-data; boundary=---7d335e13e00e0
Submitting a valid filename resulted in:
----------------------------------------------------
  \\data01\users2\budgie\diffs.txt  Latest Fullpath
  \\data01\users2\budgie\           Latest Filepath
  diffs.txt                         Latest Filename
  3566                              Latest Length
                                    Latest Status
  text/plain                        Latest Content-type

----------------------------------------------------
You can drive yourself nuts if you can't see what's going on, so just display any/every thing you _might_ need to see!

In reply to Re: Get vs. POST in CGI.pm by shenme
in thread Get vs. POST in CGI.pm by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.