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.
|