小编use*_*185的帖子

用于文件上传的 Perl 脚本

我正在尝试用 Perl 编写一个脚本,允许用户上传文件。目前,它说它正在工作,但实际上并没有上传文件!

这是代码:

 #!/usr/bin/perl
 use CGI;
 my $cgi = new CGI;
 my $dir = 'sub';
 my $file = $cgi->param('file');
 $file=~m/^.*(\\|\/)(.*)/;
 # strip the remote path and keep the filename
 my $name = $2;
 open(LOCAL, ">$dir/$name") or print 'error';
 while(<$file>) {
    print LOCAL $_;
 }
 print $cgi->header();
 print $dir/$name;
 print "$file has been successfully uploaded... thank you.\n";enter code here
Run Code Online (Sandbox Code Playgroud)

perl cgi

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

cgi ×1

perl ×1