linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘网络学院网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > article > Linux开发区 > 软件开发 >
栏目导栏
资料搜索
热门文章
·Linux 下 C 语言编程
·Linux下的通用线程池创建
·C++字符串转换篇
·linux C 进程操作篇
·linux上的C/C++编译器gcc/egcs
·linux C 文件权限控制篇
·GCC使用手册
·linux C 接口处理篇
·在Redhat Linux上安装 GCC 编译
·GCC使用指南
·C语言运算符
·Linux下C开发环境的构成和安装
·fopen()函数的参数说明
·GCC使用手册与常用命令
·Scheme 语言介绍
最新文章
·在Ubuntu Linux 8.04上构建GCC
·Linux操作系统下Socket编程地址
·将VC程序移植到Linux系统的几点
·Linux下malloc/free与new/dele
·Linux下用GTK和socket实现简单
·Linux操作系统下让Tomcat启动在
·Linux操作系统中如何编译C程序
·几种常被人们忽略的Linux系统下
·Eclipse编程工具 在Ubuntu下的
·Linux操作系统下的网络地址转换
·老手经验谈:Linux驱动程序开发
·Linux操作系统多线程同步Mutex
·Linux操作系统下C程序语言简易
·Linux系统平台下关于GCC编译及
·解决Linux系统下管道被接受方关
用 perl 实现文件上传的代码
[ 作者:  加入时间:2007-10-11 17:03:01  来自:Linux联盟收集整理 ]

示例的 HTML 文件如下:rjvLinux联盟
<html>rjvLinux联盟
<body>rjvLinux联盟
<form method="POST" action="psupload.cgi" ENCTYPE="multipart/form-data">rjvLinux联盟
File 1: rjvLinux联盟
<input type="file" name="FILE1">rjvLinux联盟
<br>rjvLinux联盟
File 2: rjvLinux联盟
<input type="file" name="FILE2">rjvLinux联盟
<br>rjvLinux联盟
<input type="submit" value="Upload!">rjvLinux联盟
</form>rjvLinux联盟
</body>rjvLinux联盟
</html>rjvLinux联盟

后台的 Perl 程序如下:

#!/usr/bin/perlrjvLinux联盟
#######################################rjvLinux联盟
## Perl Services Upload Helper v1.0 ##rjvLinux联盟
## http://www.perlservices.com ##rjvLinux联盟
## perlservices@perlservices.com ##rjvLinux联盟
## ###########################################rjvLinux联盟
## You should carefully read all of the following terms and conditions ##rjvLinux联盟
## before using this program. Your use of this software indicates your ##rjvLinux联盟
## acceptance of this license agreement and warranty. ##rjvLinux联盟
## This program is being distributed as freeware. It may be used ##rjvLinux联盟
## free of charge, but not modified below the line specified. This copyright ## rjvLinux联盟
## must remain intact. ##rjvLinux联盟
## ##rjvLinux联盟
## By using this program you agree to indemnify Perl Services from any ##rjvLinux联盟
## liability. ##rjvLinux联盟
## ##rjvLinux联盟
## Selling the code for this program without prior written consent is ##rjvLinux联盟
## expressly forbidden. Obtain permission before redistributing this ##rjvLinux联盟
## program over the Internet or in any other medium. In all cases the ##rjvLinux联盟
## copyright must remain intact. ##rjvLinux联盟
## ##rjvLinux联盟
## There are security hazards involved with this script. Read the readme file##rjvLinux联盟
## before using the script. ##rjvLinux联盟
###################################################

##rjvLinux联盟
## Start setting up options here:

## Your path to where you want your files uploaded.rjvLinux联盟
## Note: NO trailing slashrjvLinux联盟
$basedir = "/home/path/to/directory";

## Do you wish to allow all file types? yes/no (no capital letters)rjvLinux联盟
$allowall = "yes";

## If the above = "no"; then which is the only extention to allow?rjvLinux联盟
## Remember to have the LAST 4 characters i.e. .extrjvLinux联盟
$theext = ".gif";

## The page you wish it to forward to when done:rjvLinux联盟
## I.E. http://www.mydomainname.com/thankyou.htmlrjvLinux联盟
$donepage = "http://www.perlservices.com/";rjvLinux联盟

################################################rjvLinux联盟
################################################rjvLinux联盟
## DO NOT EDIT OR COPY BELOW THIS LINE ##rjvLinux联盟
################################################rjvLinux联盟
################################################

use CGI; rjvLinux联盟
$onnum = 1;

while ($onnum != 11) {rjvLinux联盟
my $req = new CGI; rjvLinux联盟
my $file = $req->param("FILE$onnum"); rjvLinux联盟
if ($file ne "") {rjvLinux联盟
my $fileName = $file; rjvLinux联盟
$fileName =~ s!^.*(\\|\/)!!; rjvLinux联盟
$newmain = $fileName;rjvLinux联盟
if ($allowall ne "yes") {rjvLinux联盟
if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){rjvLinux联盟
$filenotgood = "yes";rjvLinux联盟
}rjvLinux联盟
}rjvLinux联盟
if ($filenotgood ne "yes") { rjvLinux联盟
open (OUTFILE, ">$basedir/$fileName"); rjvLinux联盟
print "$basedir/$fileName<br>";rjvLinux联盟
while (my $bytesread = read($file, my $buffer, 1024)) { rjvLinux联盟
print OUTFILE $buffer; rjvLinux联盟
} rjvLinux联盟
close (OUTFILE); rjvLinux联盟
}rjvLinux联盟
}rjvLinux联盟
$onnum++;rjvLinux联盟
}

print "Content-type: text/html\n";rjvLinux联盟
print "Location:$donepage\n\n";

评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·使代码简洁的五条忠告  (2007-10-30 15:16:21)
 ·delphi IDE的代码完成功能  (2007-10-30 15:06:47)
 ·Javascript制作声音按钮的代码  (2007-10-30 13:53:06)
 ·如何将asp.net的后台cs代码移动到页面上  (2007-10-29 14:25:45)
 ·IE浏览器右下脚弹出的广告特效代码  (2007-10-29 13:52:47)
 ·详细解析网页漂浮广告代码的含义  (2007-10-29 13:49:01)
 ·常用的网页特殊效果JS代码  (2007-10-29 13:48:25)
 ·限制文本字节数的JS源代码程序  (2007-10-29 13:47:48)
 ·让你的ewbeditor也能运行代码  (2007-10-29 13:33:35)
 ·实现类似于Flash的超酷特效代码  (2007-10-29 13:28:52)