<label>请选择要上传的文件</label>
<form name="form1" method="post" enctype="multipart/form-data">
<table id="up_table" border=1 bgcolor="aqua">
<tr id="auto">
<td>上传文件:</td>
<td><input type="file" name="u_file[]" /></td>
<td><input type="button" name="del" value="删除" onclick="delRow(this)" id="del" /></td>
<td><input type="button" name="add" value="增加" onclick="insertRowl(this)" id="add" /></td>
</tr>
<tr>
<td>上传文件:</td>
<td><input type="file" name="u_file[]" /></td>
<td><input type="button" name="del" value="删除" onclick="delRow(this)" id="del" /></td>
<td><input type="button" name="add" value="增加" onclick="insertRowl(this)" id="add" /></td>
</tr>
<tr><td colspan="4"><input type="hidden" name="action" value="m_upload" /><input type="submit" value="上传" /></td></tr>
</table>
</form>
<script language="javascript">
function insertRowl() {
var obj=document.getElementsByName("show")[0].cloneNode(true);
document.all("auto").appendChild(obj);
}
function delRow(obj) {
var rowIndex=document.all("up_table").rows.length;
if(rowIndex>3){
obj.parentNode.parentNode.removeNode(true);
}
}
</script>
<?php
if($_POST[action]=="m_upload"){
$file_path="./uploads//";
$filename=$_FILES[u_file][name];
$tmpname=$_FILES[u_file][tmp_name];
for($i=0;$i<count($filename);$i++){
move_uploaded_file($tmpname[$i],$file_path.$i.$filename[$i]);
}
echo "文件上传成功";
}
?>