0

我想打开一个文本文件并通过使用读取前 10 行CGIPerl 我编写了脚本,但它不起作用。我的问题在哪里

#!C:/wamp/apps/Perl/bin/perl.exe -wt

use CGI;
my $cgi=CGI->new();

print 
$cgi->header('text/html'),
$cgi->start_html('Extract the text'),
$cgi->h1({-style=>'color:red;background-color:#eee;'},'Extract CGI'),
$cgi->start_form(-enctype=>&CGI::MULTIPART),
'Upload your text File: ',
$cgi->filefield(
    -name=>'filename',
    ),
$cgi->submit(-value=>'Read the File'),

my $txtfile=$cgi->param('filename'),

open my $in,$filename or die("couldnot open");
while (my $line = <$in>)
{
    print $line;
    last if $. == 10;
}
close $in;

$cgi->end_form;
$cgi->end_html;
4

1 回答 1

0

you might find this useful

http://www.sitepoint.com/uploading-files-cgi-perl-2/

basically, the file uploaded is not named the same as the file passed in from the browser

You need to do some checks on what you've been sent first

于 2013-06-21T06:17:18.783 回答