So, it looks like they tried to implement something that was very generic, and attempts to handle potential (but not certain) multiple file uploads. Too bad it ends up with only the last one.
So, for the sake of sanity, I'm trying to do as little modification as possible. I'm looking at the CGI function append(); as a possible near-drop-in replacement for the use of param('foo','new value');. At this point, I need to know one thing: does append(); do a scalar (ie, smoosh into one big string) or list (ie, push value onto the end of an array) append?
foreach my $x ($q->param()) { # if a file upload: my $filename = $q->param($x); # loop read in the file: my $filedata = $buffer; $q->param('_filename', $filename); $q->param('_filedata', $filedata); } # a bunch of other stuff. # this is to :sigh: mail the file to someone remote $q->param('_filedata',encode_base64($q->param('_filedata'))); # stuff the data into an attachment by hand
As you'll notice, the values of $q->param('_filedata'); and $q->param('_filename'); are overwritten every time through this loop. I'm not sure what the heck the original author was thinking, but he's (of course) not here now.
So, I'm hoping that $q->append(); will help me here by making an array out of _filedata and _filename. Think it will?
In reply to CGI.pm file uploads in very generic script by amelinda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |