Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

file upload form

by amt (Monk)
on Dec 28, 2004 at 20:12 UTC ( #417834=perlquestion: print w/ replies, xml ) Need Help??
amt has asked for the wisdom of the Perl Monks concerning the following question:

Gentlemen,

I have been asked to create a form to upload CSV of site surveys, and then emailing that file to my engineering department.

The HTML half of the script is as follows:
<form name=csvsurvey method=post action='/' enctype='multipart/form-da +ta'> <input type=hidden name=cmd value=main> <input type=hidden name=module value=Customer> <input type=hidden name=sub_cmd value=site_csv> <input type=hidden name=sub_module value='Site Survey'> <tr><td class=oatable>CSV File to Upload</td><td class=oatab +le><input type=file name=upfile></td></tr> <tr><td class=oatable>Notes(80 char max)</td><td class=oatabl +e><input type=text name=upnote maxlength=80></td></tr> <tr><td class=oatable colspan=2 align=center><input type=subm +it value='Upload File'></td></tr></form>
The function that handles the incoming file is as follows:
sub site_csv() { # Get CGI Variables CGI::ReadParse(*form); my $csv = $form{upfile}; $csv =~ s/\n/<br>/gi; my $note= $form{upnote}; $tokens{MAIN} = "Included note: $note<br>"; $tokens{MAIN} .="<br>$csv<br>"; return $tokens{MAIN}; }
As you can tell I haven't even gotten to the point where I need to attach the file to an email. I want to be able make sure that I can recieve the information. The problem is that when I send my file, test.csv, printing out $form{upfile} prints the file name of the file that was uploaded, rather than the data.

TIA,
amt.

perlcheat

Comment on file upload form
Select or Download Code
Re: file upload form
by steves (Curate) on Dec 28, 2004 at 20:36 UTC

    If you read the CGI docs carefully, you'll see that uploaded files are presented to the CGI application as both a name and a filehandle. Those docs illustrate usage better than I can.

      Thank you. It's near the end of the day, so I was trying to avoid the whole RTFM ;). I'll read the docs.
      amt.

      perlcheat

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://417834]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2015-07-06 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls