Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Uploading a CSV file using the input file html form object

by master_son (Acolyte)
on Jan 25, 2006 at 22:10 UTC ( #525580=perlquestion: print w/replies, xml ) Need Help??

master_son has asked for the wisdom of the Perl Monks concerning the following question:

Can someone tell me a good method of uploading a csv file via CGI so that I could read its contents with DBI? All I would like to do is get file stored on the server so it can be opened by perl code and read.

Here is a code snippet I created to test interaction in the CGI for getting information on the name and type of file:
use CGI qw(:standard); print "Content-type: text/html\n\n"; &main; sub main() { my $query = new CGI; my $indexTemp = HTML::Template->new(filename => 'index.tmpl'); my $fileName = $query->param('filepath'); my $type = $query->uploadInfo($fileName)->{'Content-Type'}; print $query->param('eventname')."<br />\n"; print $query->param('date')."<br />\n"; print $query->param('starttime')."<br />\n"; print $query->param('endtime')."<br />\n"; print $query->param('location')."<br />\n"; print $fileName."<br />\n"; print $type."<br />\n"; } }
Thank you in advance for your help.
---------------------
Keep your concentration here and now where it belongs - Qui-Gon Jinn

Replies are listed 'Best First'.
Re: Uploading a CSV file using the input file html form object
by lima1 (Curate) on Jan 25, 2006 at 22:27 UTC
    use the upload() function (perldoc CGI).

    in your upload_results page, you must check what you got (valid file handle? cgi_error? correct format?). Then simply store the data (open my $FH, '>', $secure_destination), or store it directly in db.

      Thank you, this helped!
      ---------------------
      Keep your concentration here and now where it belongs - Qui-Gon Jinn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2022-10-05 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (20 votes). Check out past polls.

    Notices?