CGI file upload example
#!/usr/local/bin/perl
use CGI;
$co = new CGI;
if (!$co->param())
{
print
$co->header,
$co->start_html('CGI File Upload Example'),
$co->center
(
$co->start_multipart_form,
$co->filefield(-name=>'filename', -size=>30),
$co->br,
$co->submit(-value=>'Upload'),
$co->reset,
$co->end_form
),
$co->hr;
} else {
print
$co->header,
$co->start_html('');
$file = $co->param('filename');
@data = <$file>;
foreach (@data) {
s/\n/<br>/g;
}
print
$co->center($co->h2("Here's the contents of $file...")),
"@data";
}
print $co->end_html;
Related examples in the same category