There are all sorts of technical problems with this. First you need to understand that what you think of as some form params and some file arrives at the server as a text stream that looks like:

# a form <form method="POST" action="http://domain.com/cgi-bin/dump.txt?sending=query&string=as +&well" enctype="multipart/form-data"> <input type="file" name="upload_file1"> <input type="text" name="text1"> <input type="text" name="text2"> <input type="text" name="text3"> <input type="file" name="upload_file2"> <input type="submit" value="Submit" name="submit"> </form> # a very simple script [root@devel3 cgi-bin]# cat dump.txt #!/usr/bin/perl print "Content-Type: text/plain\n\n"; print "QUERY STRING: ", $ENV{QUERY_STRING},"\n\n\n"; print while <> # what actually happens QUERY STRING: sending=query&string=as&well -----------------------------7d43d8850366 Content-Disposition: form-data; name="upload_file1"; filename="C:\Docu +ments and Settings\Administrator\My Documents\My Pictures\120x200-osc +on04.gif" Content-Type: image/gif GIF89a..!..,.....D; -----------------------------7d43d8850366 Content-Disposition: form-data; name="text1" foo -----------------------------7d43d8850366 Content-Disposition: form-data; name="text2" bar -----------------------------7d43d8850366 Content-Disposition: form-data; name="text3" baz -----------------------------7d43d8850366 Content-Disposition: form-data; name="upload_file2"; filename="C:\Docu +ments and Settings\Administrator\My Documents\My Pictures\bckgrnd.gif +" Content-Type: image/gif GIF89a..,.......; -----------------------------7d43d8850366 Content-Disposition: form-data; name="submit" Submit -----------------------------7d43d8850366--

So there are all sorts of take home points. First if you can arrange for your 'vital' form data to go via the query string you are guaranteed it will be immediately available. All you should need is the SESSID (that is all you need right?) so that should be an option.

Next you will note that the order of the text stream mirrors that of the form data fields. So you get the params after the first file.

Finally you need to know that the first thing a CGI/CGI::Simple object does when you call new() is to strip the POST data off STDIN. Data on STDIN is *gone* once it is read so you can't have a sneak peak as it were. The CGI parsers need the whole stream so you really need to use $ENV{QUERY_STRING} to get your vital data and delay the call to new(). If you can do that you can fork of a child to look after the downloading and then it is just an IPC problem.

Note you can call new like this: my $q = CGI->new($ENV{QUERY_STRING}) and you object will just contain the q string parse, not parse of any data on STDIN.

cheers

tachyon


In reply to Re: Deferred/selective processing in CGI.pm by tachyon
in thread Deferred/selective processing 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.