  
- UID
- 1
- 威望
- 1240 点
- 金钱
- 24019 金币
- 点卡
- 317 点
|
1#
发表于 2005-8-25 20:02
| 只看该作者
用 perl 实现文件上传
作者:keendom
email: keendom@sina.com
日期:00-6-29 13:28:47
示例的 HTML 文件如下:- <html>
- <body>
- <form method="POST" action="psupload.cgi" ENCTYPE="multipart/form-data">
- File 1:
- <input type="file" name="FILE1">
- <br>
- File 2:
- <input type="file" name="FILE2">
- <br>
- <input type="submit" value="Upload!">
- </form>
- </body>
- </html>
复制代码 后台的 Perl 程序如下:- #!/usr/bin/perl
- #######################################
- ## Perl Services Upload Helper v1.0 ##
- ## http://www.perlservices.com ##
- ## perlservices@perlservices.com ##
- ## ###########################################
- ## You should carefully read all of the following terms and conditions ##
- ## before using this program. Your use of this software indicates your ##
- ## acceptance of this license agreement and warranty. ##
- ## This program is being distributed as freeware. It may be used ##
- ## free of charge, but not modified below the line specified. This copyright ##
- ## must remain intact. ##
- ## ##
- ## By using this program you agree to indemnify Perl Services from any ##
- ## liability. ##
- ## ##
- ## Selling the code for this program without prior written consent is ##
- ## expressly forbidden. Obtain permission before redistributing this ##
- ## program over the Internet or in any other medium. In all cases the ##
- ## copyright must remain intact. ##
- ## ##
- ## There are security hazards involved with this script. Read the readme file##
- ## before using the script. ##
- ################################################################################
- ##
- ## Start setting up options here:
- ## Your path to where you want your files uploaded.
- ## Note: NO trailing slash
- $basedir = "/home/path/to/directory";
- ## Do you wish to allow all file types? yes/no (no capital letters)
- $allowall = "yes";
- ## If the above = "no"; then which is the only extention to allow?
- ## Remember to have the LAST 4 characters i.e. .ext
- $theext = ".gif";
- ## The page you wish it to forward to when done:
- ## I.E. http://www.mydomainname.com/thankyou.html
- $donepage = "http://www.perlservices.com/";
- ################################################
- ################################################
- ## DO NOT EDIT OR COPY BELOW THIS LINE ##
- ################################################
- ################################################
- use CGI;
- $onnum = 1;
- while ($onnum != 11) {
- my $req = new CGI;
- my $file = $req->param("FILE$onnum");
- if ($file ne "") {
- my $fileName = $file;
- $fileName =~ s!^.*(\\|\/)!!;
- $newmain = $fileName;
- if ($allowall ne "yes") {
- if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){
- $filenotgood = "yes";
- }
- }
- if ($filenotgood ne "yes") {
- open (OUTFILE, ">$basedir/$fileName");
- print "$basedir/$fileName<br>";
- while (my $bytesread = read($file, my $buffer, 1024)) {
- print OUTFILE $buffer;
- }
- close (OUTFILE);
- }
- }
- $onnum++;
- }
- print "Content-type: text/html\n";
- print "Location:$donepage\n\n";
复制代码 |
我是一个呼吸着现在的空气而生活在过去的人
这样的注定孤独,孤独的身处闹市却犹如置身于荒漠
我已习惯了孤独,爱上孤独
他让我看清了自我,还原了自我
让我再静静的沉思中得到快乐和满足
再孤独的世界里我一遍又一遍
不厌其烦的改写着自己的过去
延伸到现在与未来
然而那只是泡沫般的美梦
产生的时刻又伴随着破灭的到来
在灰飞烟灭的瞬间我看到的是过程的美丽
而不是结果的悲哀。。。
|
|