动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 一个多文件上传的例子

作者来源: 
阅读 数 374 人次 , 2006-3-29 4:16:00 


<?
//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>

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:php中文件上传的安全问题
· 下一篇:ftp类(example.php)
· 递归列出所有文件和目录
· 一个用PHP+MYSQL实现论坛里的分级+分页显示的例程
· PHP4的核心:Zend
· 开头显示X-Powered-By: PHP/4.0.0
· MySQL以速度为目标


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077