I need to transfer/extract the name value of a "form upload file field" .
I need a method so the <input type="file" size="10" name="shared_logo_filename"> field can pass the value to the next page like the text fields.
I did a search for "file upload" but none of the results addresses this issue. I am using CGI.pm, however it resides on a hosted server.

Initial file upload:
# upload some files? if (%$p_upload_files) { $err = &ui_Upload($p_upload_files); next Err if ($err); my $key = ''; foreach $key (keys %$p_upload_files) { my $p_hash = $$p_upload_files{$key}; next unless (($p_hash) and (defined($$p_hash{'serv +er file name'}))); $FORM{$key . "_filename"} = $$p_hash{'server file +name'}; delete $FORM{$key}; } } }

and for the text fields:
my %replace = (); $text = ''; my ($name, $value) = (); while (($name, $value) = each %FORM) { $replace{$name} = $value; next if ($name =~ m!^(shared|genesis_system)_!); next if (($name eq 'Action') or ($name eq 'Template') or ( +$name eq 'CWD') or ($name eq 'web_auth_cp')); $text .= &ue($name) . '=' . &ue($value) . "\n"; } &_load_system_values( \%replace, $FORM{'Template'} );

# save the name-value pairs that are specific to this template:
my $datafile = ".$FORM{'Template'}"; $datafile =~ s!/!.!g; $err = &WriteFile( $datafile, $text ); next Err if ($err);

This stores the information in the .shared.template for later retrieval so when a user opens a form
to make changes the information is still present in that particular form.
# save the name-value pairs that are specific to this template:

my $datafile = ".$FORM{'Template'}"; $datafile =~ s!/!.!g; $err = &WriteFile( $datafile, $text ); next Err if ($err);

# save the name-value pairs that are shared. This operation is a merge:
$datafile = '.shared.template'; my $shared = ''; if (-e $datafile) { ($err, $text) = &ReadFile($datafile); foreach (split(m!\n!, $text)) { next unless (m!^(.+)\=(.*)$!); next if (defined($FORM{"shared_$1"})); $shared .= "$_\n"; } } foreach (keys %FORM) { next unless (m!^shared_(.+)$!); $shared .= &ue($1) . '=' . &ue($FORM{$_}) . "\n"; } $err = &WriteFile($datafile, $shared); next Err if ($err);

Edited by planetscape - added (a few more) code tags

Edit: g0n - readmore tags


In reply to Extract and Pass File Upload Value by rick

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.