奇趣技术网 收藏本站
设为主页
商务合作
首页 新闻中心 行业动态 软件新闻 安全资讯 病毒预警 漏洞发布 操作系统 Dos Win9x Win2000 WinXP Win2003 WinVista Linux Unix
数据库 DB2 Access MSSQL MySQL Oracle Sybase 编程技术 ASP PHP JSP CGI/Perl XML .Net C/C++/C# VB VC Delphi Java 汇编
安全技术 安全教学 工具介绍 漏洞利用 病毒防范 入侵检测 防火墙 安全防范 汉化破解 攻击实例 加密解密 技术论坛
中华网络安全联盟 >> 程序开发 >> Perl >> 用 perl 实现文件上传
程序开发
Asp
PHP
JSP
CGI/Perl
XML
.Net
C/C++/C#
Visual Basic
Visual C++
Delphi
Java
汇编语言
  • LB5000XP论坛配合SERV

  • 获取随机的由大小写字

  • Perl操作Mysql数据库

  • Perl在NT下的快速简便

  • 用Perl制作页面计数器

  • 用Perl语句来代替常用

  • perl 域名查询程序

  • 在Linux下访问MS SQL 

  • 用 perl 实现文件上传
    字体:

    中华网络安全联盟    作者:佚名    来源:网络转载    时间:2006-3-21


    示例的 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";

    字体:
     
    设为主页 收藏本站 联系我们 友情连接 商务合作 网友留言
    Copyright©2006-2008 中华网络安全联盟 All rights reserved.