一个多文件上传的例子(原创)
一个多文件上传的例子(原创)
发布时间:2016-12-29 来源:查字典编辑
摘要:多个文件上传functionwindow.onload(){document.forms[0].btnOk.onclick=btn_ok;}...

<?

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

<>

</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" border="0">

<tr height="35"><td align="right" valign="bottom">多文件上传</td></tr>

<tr><td align="center" valign="top">

<table border="0" 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" name="afile1"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件2</label></td>

<td><input type="file" tabindex="2" name="afile2"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件3</label></td>

<td><input type="file" tabindex="3" name="afile3"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件4</label></td>

<td><input type="file" tabindex="4" name="afile4"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件5</label></td>

<td><input type="file" tabindex="5" name="afile5"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件6</label></td>

<td><input type="file" tabindex="6" name="afile6"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件7</label></td>

<td><input type="file" tabindex="7" name="afile7"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td></td>

<td nowrap><label>文件8</label></td>

<td><input type="file" tabindex="8" name="afile8"style="WIDTH: 282px"></td>

<td></td>

</tr>

<tr>

<td>

<td colspan="2"><hr width="100%"></td>

<td></td>

</tr>

<tr>

<td></td>

<td colspan="2" align="left">

<button tabindex="5" align="center" name="btnOk" id="btnOk" accesskey="O">确定(<ins>O</ins>)</button>

<input type="hidden" name="ifupload" value=1>

<button tabindex="5" align="center" name="btnCancel" id="btnCancel" 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>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类