php上传多张图片

最简单的形式是

<form encType="multipart/form-data" action="upAll.php" method="POST">
<input name="upload[0]" type="file" /><br/>
<input name="upload[1]" type="file" /><br/>
<input type="submit" value="上传" />
</form>


------------------------------------------------------------------------------------------------------

<?php
 foreach($_FILES['upload']['name'] as $index =>$name){


//echo $name."<br/>";
$tmp = explode('.',$name); //explode 函数
    $docName = time().rand(1,1000).".".$tmp[1];
$uploadfile = "up/".$docName;
if(move_uploaded_file($_FILES['upload']['tmp_name'][$index],$uploadfile)){
echo "文件".$name."上传成功<br/>";
}else{
echo "文件".$name."上传失败<br/>";
}
 }
?>

posted @ 2011-09-18 22:40  夏至冬末  阅读(115)  评论(0编辑  收藏  举报