0
点赞
收藏
分享

微信扫一扫

php多文件上传


php多文件上传_上传

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>无标题文档</title>
</head>

<body>
<form  method="post" action="" enctype="multipart/form-data">
	<table id="up_table"   border="1"  bgcolor="#CC6600"> 
	 <tbody id="auto">
	   <tr id="show">
	     <td>上传文件</td>
	     <td><input name="u_file[]" type="file"></input></iput></td>
	   </tr>
	   <tr>
	     <td>上传文件</td>
	     <td><input name="u_file[]" type="file"></input></td>
	   </tr>
	 </tbody>
	 <tr>
	   <td colspan="4"><input type="submit" value="上传"></input></td>
	 </tr> 
</form>     
    </table>
</form>
<!-- 判断变量$_files是否为空 -->
<?php
error_reporting(E_ALL & ~E_NOTICE);  
    if(!empty($_FILES[u_file][name])){
        $file_name=$_FILES[u_file][name];  //将上传文件名另存为数组
        $file_temp_name=$_FILES[u_file][tmp_name]; //将上传的临时文件名存为数组
        for($i=0; $i<count($file_name);$i++){ //循环上传文件
            if($file_name[$i]!=""){  //判断上传文件名是否为空
                move_uploaded_file($file_temp_name[$i], $i.$file_name[$i]);
                echo '文件'.$file_name[$i].'上传成功。更名为'.$i.$file_name[$i].'<br>';
            }
        }
    }

?>

</body>
</html>


php多文件上传_文件名_02


举报

相关推荐

0 条评论