一个多文件上传的例子(原创)


<?
//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=https://www.jb51.net/article/\"multi_upload.php\">Return</a>";
   exit;
}
?>

<html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta 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" enctype="multipart/form-data" >
<table>
  <tr><td valign="bottom">多文件上传 </td></tr>
  <tr><td valign="top">

    <table cellspacing="0" cellpadding="0">

    <tr >
        <td></td>
        <td colspan="2"></td>                
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件1</label></td>
        <td><input type="file" tabindex="1"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件2</label></td>
        <td><input type="file" tabindex="2"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件3</label></td>
        <td><input type="file" tabindex="3"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件4</label></td>
        <td><input type="file" tabindex="4"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件5</label></td>
        <td><input type="file" tabindex="5"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件6</label></td>
        <td><input type="file" tabindex="6"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件7</label></td>
        <td><input type="file" tabindex="7"  style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td nowrap><label>  文件8</label></td>
        <td><input type="file" tabindex="8"   style="WIDTH: 282px"></td>
        <td></td>
    </tr>
    <tr>
        <td>
        <td colspan="2"><hr></td>                
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td colspan="2">
            <button tabindex="5" accesskey="O">确定(<ins>O</ins>)</button>
            <input type="hidden" value=1>
            <button tabindex="5" accesskey="C">取消(<ins>C</ins>)</button></td>    
        <td></td>
    </tr>
    <tr>
        <td>
        <td colspan="2"></td>                
        <td></td>
    </tr>
    </table>
  </td>
  </tr>
</table>
</form>
</body>
</html>

相关文章

最新评论

站长推荐

正版 Windows 10

正版Windows 10 家庭/专业版,操作系统限时抢购[¥1088→¥248]

站长推荐

正版 Office 软件

Microsoft Office 2016/2019/365 正版最低价仅需[ ¥148元]

大家感兴趣的内容

最近更新的内容

常用在线小工具

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/44ab993c55375fb8cffd117b93ded7b9.html