问: 使用WebShell,不能上传大于2M的文件,如何是好?
答: 可以使用Perl脚本尝试上传大于2M的文件,以下的示例来自perlmonks.org的
cLive引用:
#!/usr/bin/perl -w
use strict;
# make html/forms easy to deal with
use CGI;
# report errors in the browser
# (remove from production code)
use CGI::Carp 'fatalsToBrowser';
# create new CGI object
my $q = new CGI;
if ( ! $q->param() )
{
# first run, so present form
print
$q->header,
$q->start_html,
$q->start_multipart_form,
$q->filefield('file'),
$q->br,
$q->submit('Upload'),
$q->end_form,
$q->end_html;
}
else
{
# file uploaded, so process it
# read filehandle from param and set to binary mode
my $filehandle = $q->param('file');
binmode $filehandle;
# open file for output. Change this to suit your needs!!!
open OUT, "> /path/to/local/filename" or die $!;
binmode OUT;
# process $filehandle
{
my $buffer;
while ( read $filehandle, $buffer, 1024 )
{
print OUT $buffer;
}
}
close OUT;
# show success
print
$q->header,
$q->start_html,
$q->p('File uploaded'),
$q->end_html;
}
过程:
- 在空间的cgi-bin目录里新建包含上述内容的pl文件,如保存为fu.pl
- 将fu.pl文件中的第36行,=/path/to/local/filename= 修改成符合自己要求的,文件保存路径及文件名
- 通过浏览器,访问fu.pl文件,上传大于2M的文件
结果:
注意:
- 建议使用FTP客户端大于2M的文件
- 用PHP的脚本也可以达到目的,但须修改PHP默认的,上传文件不大于2M的设置
附图:
图1:通过浏览器,使用Perl脚本上传文件
图2:通过浏览器,使用Perl脚本成功上传大于6M的文件