[PerlChina] 通过cgi.pm上传文件

黄叶 hylinux at gmail.com
Sun Jan 15 05:58:50 PST 2006


好冷清啊。
我来提一个问题呵呵。大家帮帮忙。
我使用cgi.pm来上传文件,
使用mod_perl.
下面是我的mod_perl的配置:

Alias /perl/ /home/ghw/myperl/webproject/
 PerlSwitches -T
 <Location "/perl/">
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
    Order allow,deny
     Allow from all
 </Location>

代码很简单:
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

$CGI::DISABLE_UPLOADS = 0;
$CGI::POST_MAX = -1;

my $q = CGI->new;

my $filename = $q->param("file");

print $q->header("text/html;charset=gb2312");

print $filename;

open OUTPUT, ">upload/$filename" or die "$!";
binmode $filename;
binmode OUTPUT;

my $buffer;

while ( read($filename, $buffer, 1024) ) {
   print OUTPUT $buffer;
}

close(OUTPUT);

运行后,出现这样的错误:
Software error:

Insecure dependency in open while running setgid at
/home/ghw/myperl/webproject/upload.pl line 22.

 For help, please send mail to the webmaster (you at example.com), giving this
error message and the time and date of the error.

日志记录:
[Sun Jan 15 22:05:23 2006] [error] [Sun Jan 15 22:05:23 2006] -e: Insecure
dependency in open while running setgid at
/home/ghw/myperl/webproject/upload.pl line 22.\n

我隐约觉的是-T的关系。
但是不知道如何去修正这个问题。请知道的朋友支个招。
谢谢。
-------------- next part --------------
q?????!???,r??m??m???????j+??j)r?j??j?r????:?y?~??!???


More information about the China-pm mailing list