1、
<form method="post" enctype="multipart/form-data" action='请求地址' >
<input name="photos[]" type="file" />
<input name="photos[]" type="file" />
</from>
2、
/*多图片上传*/
public function actionUpload(){
$valid_formats = array("jpg", "png", "gif","jpeg");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
$uploaddir = '图片地址';
foreach ($_FILES['photos']['name'] as $name => $value){
$filename = stripslashes($_FILES['photos']['name'][$name]);
$size=filesize($_FILES['photos']['tmp_name'][$name]);
$model = new Upload();
$ext = $model->getExtension($filename);
$ext = strtolower($ext);
if(in_array($ext,$valid_formats)){
$img_name = 'img_'.uniqid();
$year = date('Y',time());
$month = date('m',time());
$day = date('d',time());
$time = $year.'/'.$month.'/'.$day;
$image_name=$time.$img_name.$filename;
$newname=$uploaddir.$image_name;
if (!file_exists($uploaddir.'/'.$year.'/'.$month)){
mkdir($uploaddir.'/'.$year.'/'.$month,0777,true);
}
@move_uploaded_file($_FILES['photos']['tmp_name'][$name],$newname);
$images[] = $uploaddir.$image_name;
return $images;
}
}
}
}
}