Look! I'm use CGI;ing! And you all thought I couldn't do it. Sadly, it is still legacy code. Arkayne legacy code.

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?

FWIW, here is some sample code:

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

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.