in reply to How to do an HTTP post for multiple files using HTTP::Request::Common ?

Construct the pairs filen => $files[n-1] in a loop and pass these pairs in the constructor:

my @fileargs = map { "file$_" => [ $files[$_-1]] } 1..scalar @files; my $ua = LWP::UserAgent->new(); my $req = POST $url, Content_Type => 'form-data', Content => [ submit => 1, @fileargs, ];
  • Comment on Re: How to do an HTTP post for multiple files using HTTP::Request::Common ?
  • Download Code