How to parse a multipart form in CGI/PERL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheWeapon
    New Member
    • Nov 2008
    • 2

    How to parse a multipart form in CGI/PERL?

    Im trying to parse form data from a form that has an input type: file, which requires a multipart encode. The form also has other input text boxes, the names of which are populated on the fly so the names of the text boxes are unknown to hard code into the script that parses the form. Most of the research I've done on how to parse multipart forms suggests to use a format such as the following:

    $mycgi = new CGI;
    print $mycgi->header;

    # get the file from the input stream
    $upload = $mycgi->param("UPLOAD" );

    Is it possible for me to get the names and values of the unknown text fields with this type of parsing? If so, how? Thanks for any assitance in advance
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    You could use the following.

    Code:
    my %params = $q->Vars;
    
    while (my ($key, $value) = each %params) {
    	print "Key: $key\tValue: $value\n";
    }
    --Kevin

    Comment

    • TheWeapon
      New Member
      • Nov 2008
      • 2

      #3
      The Vars method is exactly what I was looking for, tyvm Kevin helped me tremedously.

      Comment

      Working...