• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

一个多文件上传的例子

发布: 2007-7-14 19:53 | 作者: 佚名    | 来源: 网络转载     | 查看: 8次 | 进入软件测试论坛讨论

领测软件测试网


<?
//filename:multi_upload.php
if($ifupload)
{
  $path=AddSlashes(dirname($PATH_TRANSLATED))."\\upload\\";
  for($i=1;$i<=8;$i++)
  {
     $files="afile".$i;
     if(${$files}!="none")
     {
        if(copy(${$files},$path.${$files."_name"}))
        {
          
        }
     }
   }
   print "<b>You have uploaded files successfully</b><br>";
   print "<a href=\"multi_upload.php\">Return</a>";
   exit;
}
?>

<html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>多个文件上传</title>
<style type="text/css">
<!--
BODY
{
    PADDING-RIGHT: 0px;
    MARGIN-TOP: 0px;
    PADDING-LEFT: 0px;
    FONT-SIZE: 8px;
    MARGIN-LEFT: 0px;
    CURSOR: default;
    COLOR: black;
    MARGIN-RIGHT: 0px;
    PADDING-TOP: 0px;
    FONT-FAMILY: Arial;
    BACKGROUND-COLOR: transparent;
    TEXT-ALIGN: center
}
.TxtInput
{
    FONT-SIZE: 8pt;
    WIDTH: 100%;
    CURSOR: default;
    COLOR: black;
    FONT-FAMILY: Arial;
    HEIGHT: 21px;
    BACKGROUND-COLOR: white;
    TEXT-ALIGN: left
}
.FieldLabel
{
    FONT-WEIGHT: normal;
    FONT-SIZE: 9pt;
    WIDTH: 100%;
    COLOR: black;
    FONT-FAMILY: Arial;
    BACKGROUND-COLOR: transparent;
    TEXT-ALIGN: left
}
.HeadBtn
{
    BORDER-RIGHT: black 1px solid;
    BORDER-TOP: white 1px solid;
    FONT-SIZE: 8pt;
    OVERFLOW: hidden;
    BORDER-LEFT: white 1px solid;
    WIDTH: 70px;
    COLOR: black;
    BORDER-BOTTOM: black 1px solid;
    FONT-FAMILY: Arial;
    HEIGHT: 21px;
    BACKGROUND-COLOR: #8e8dcd;
    TEXT-ALIGN: center
}
.TransEx
{
    BORDER-RIGHT: black 1px solid;
    PADDING-RIGHT: 8px;
    BORDER-TOP: white 1px solid;
    PADDING-LEFT: 8px;
    FONT-SIZE: 8pt;
    PADDING-BOTTOM: 3px;
    BORDER-LEFT: white 1px solid;
    WIDTH: 720px;
    PADDING-TOP: 3px;
    BORDER-BOTTOM: black 1px solid;
    FONT-FAMILY: Arial;
    BACKGROUND-COLOR: #c0c0c0;
    TEXT-ALIGN: center
}
-->
</style>
<script language="javascript">
function window.onload()
{
    document.forms[0].btnOk.onclick=btn_ok;
}
function btn_ok()
{
    for(var i=1;i<=8;i++)
    {
     if(eval("document.forms[0].afile"+i+".value!=''"))
       document.forms[0].submit();
      return true;
    }
    alert("None of file have been selected");
    return false;
}
</script>
</head>

<body>
<form method="post" action="multi_upload.php" name="frmUpload" enctype="multipart/form-data" >
<table id="divContainer" style="HEIGHT: 100%; WIDTH: 380" border="0">
  <tr height="35"><td align="right" valign="bottom">多文件上传 </td></tr>
  <tr><td align="center" valign="top">

    <table class="Transex" border="0" cellspacing="0" cellpadding="0" style="WIDTH: 360px">
    
    <tr style="HEIGHT: 10px" >
        <td style="WIDTH: 5px"></td>
        <td colspan="2"></td>                
        <td style="WIDTH: 5px"></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件1</label></td>
        <td><input type="file" class="TxtInput" tabindex="1" name="afile1"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件2</label></td>
        <td><input type="file" class="TxtInput" tabindex="2" name="afile2" style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件3</label></td>
        <td><input type="file" class="TxtInput" tabindex="3" name="afile3"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件4</label></td>
        <td><input type="file" class="TxtInput" tabindex="4" name="afile4"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件5</label></td>
        <td><input type="file" class="TxtInput" tabindex="5" name="afile5"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件6</label></td>
        <td><input type="file" class="TxtInput" tabindex="6" name="afile6"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件7</label></td>
        <td><input type="file" class="TxtInput" tabindex="7" name="afile7"  style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label class="FieldLabel">  文件8</label></td>
        <td><input type="file" class="TxtInput" tabindex="8" name="afile8"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr style="HEIGHT: 5px">
        <td style="WIDTH: 5px">
        <td style="WIDTH: 350px" colspan="2"><hr width="100%"></td>                
        <td style="WIDTH: 5px"></td>
    </tr>
    <tr>
        <td></td>
        <td colspan="2" align="left">
            <button tabindex="5" class="headbtn" align="center" name="btnOk" id="btnOk" accesskey="O">确定(<ins>O</ins>)</button>
            <input type="hidden" name="ifupload" value=1>
            <button tabindex="5" class="headbtn" align="center" name="btnCancel" id="btnCancel" accesskey="C" onclick="window.close();">取消(<ins>C</ins>)</button></td>    
        <td></td>
    </tr>
    <tr style="HEIGHT: 5px">
        <td style="WIDTH: 5px">
        <td style="WIDTH: 350px" colspan="2"></td>                
        <td style="WIDTH: 5px"></td>
    </tr>
    </table>
  </td>
  </tr>
</table>
</form>
</body>
</html>

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网