38 lines
751 B
Perl
38 lines
751 B
Perl
|
#!/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;
|