submit.html
<html>
<head>
<meta charset="utf-8">
<title>文件上传</title>
</head>
<body>
<h1 style="color:white;background-color:#525D76;font-size:22px;text-align: center">文件上传</h1>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="1000000"/>
<table border="0">
<tr>
<th align="right" valign="top">上传文件:</th>
<td>
<input type="file" name="fl[]" size:"60"><br/>
<input type="file" name="fl[]" size:"60"><br/>
<input type="file" name="fl[]" size:"60"><br/>
<input type="checkbox" name="forbid" value="true"/>是否覆盖同名文件<br/>
<input type="submit" name="" value="上传"/>
</td>
</tr>
</table>
</form>
</body>
</html>
upload.php
<html>
<head>
<meta charset="utf-8">
<title>上传结果</title>
</head>
<body>
<h1 style="color:white;background-color:#525D76;font-size:22px;text-align: center">上传结果</h1>
<table border='1' width="350">
<tr>
<th>文件名</th><th>大小</th><th>MINE类型</th>
</tr>
<?php
$path='./File/';
$num=0;
for ($i=0; $i < sizeof($_FILES['fl']['name']); $i++) {
$name = mb_convert_encoding($_FILES['fl']['name'][$i],'GB2312','UTF-8');
if($_FILES['fl']['name'][$i] == ''){
continue;
}
if(file_exists($path.$name) == TRUE&&$_POST['forbid'] == 'true'){
$num++;
}elseif (!is_uploaded_file($_FILES['fl']['tmp_name'][$i])) {
$num++;
}else{
?>
<tr>
<td align="right"><?php print($_FILES['fl']['name'][$i]);?></td>
<td align="right"><?php print($_FILES['fl']['size'][$i]);?>byte</td>
<td align="right"><?php print($_FILES['fl']['type'][$i]);?></td>
</tr>
<?php
move_uploaded_file($_FILES['fl']['tmp_name'][$i],$path.$name);
}
}
if($num>0){
print('<div style="color:red">'.$num.'件上传失败</div>');
}
?>
</table>
</body>
</html>