http://www.perlmonks.org?node_id=939522


in reply to Uploading and reading file

Here's what I found. Make sure that you run it with -T on the cmdline. I left out the csv section to concentrate on CGI.
#!/usr/bin/perl -lT use strict; use Fcntl qw/:DEFAULT :flock/; use CGI::Carp qw/fatalsToBrowser/; use CGI qw/:standard -private_tempfiles/; $CGI::POST_MAX = 1024 * 1024 * 50; $CGI::DISABLE_UPLOADS = 0; use constant UPLOAD_DIR => '/tmp'; use constant BUFFER_SIZE => 16384; use constant MAX_DIR_SIZE => 1024 * 1024 * 100; use constant MAX_OPEN_TRIES => 100; my $q = new CGI; print $q->header( "text/html", -expires => "-1s" ), $q->start_html( -title => "Wordcloud Generator", -bgcolor => "#ffffff", -head => $q->meta( { -http_equiv => 'Pragma', -content => 'no-cache' } ) ), $q->h2("Wordcloud Generator"), $q->hr, $q->p( "Processed file:", my $file ), $q->end_html; my $in = $q->upload('file'); $in = param('upload'); if (not $in && cgi_error()) { print $q->header(-status => cgi_error()); exit 0; }