ThinkPHP 多图片上传
public function feedback(){ $loginck = A('Index')->check(); //模块 $adminmodule = session('adminmodule'); //权限 $adminaccess = session('adminaccess'); //管理员id $adminid = session('adminid'); $userquestion = D('userquestion'); if($_GET['id']) { $data = $userquestion->get_question($_GET['id']); //判断此用户是否存在问题 和 此用户是否已经解答问题 if(!$data || $data['state'] == 1){ $this->error('未获得此用户问题');exit; } } //提交反馈答案 if($_POST) { if($_POST['answer'] == '' ){ $this->error('未填写内容');exit; } //上传多文件 $var = $_FILES['photo']['name']; //删除空着的图片 $var = array_filter($var); //不够3张 if(count($var)<3){ $this->error('图片上传不够3张');exit; } import('ORG.Net.UploadFile'); $upload = new \Org\Net\UploadFile(); foreach ($_FILES as $key=>$file) { if(!empty($file['name'])) { $upload->allowExts = array('jpg', 'gif', 'png','jpeg'); $upload->savePath = './Public/uploads/user/'.$_POST['uid'].'/'; $info = $upload->uploadOne($file); if(!$info) { // 保存附件信息 $this->error($upload->getErrorMsg());die; } } } $dir='./Public/uploads/user/'.$_POST['uid'].'/'; $file=scandir($dir); $savename = $file[2].','.$file[3].','.$file[4].','; $save = array(); $save['aid'] = $adminid; $save['state'] = 1; $save['answer'] = $_POST['answer']; $save['pic'] = $savename; $rs = $userquestion->add_answer($_POST['uid'],$save); if(!$rs){ $this->error('反馈信息失败,请重试');exit; } //反馈成功修改用户表用户状态 $customer = D('customer'); $customer->updatastate($_POST['uid'],array('state'=>'6')); //修改申请表用户状态 $claim = D('claim'); $rs1 = $claim->save_claim($_POST['uid'],6); $this->success('反馈信息成功',U('Cadmin/user_confirmlist'));exit; } $this->assign('data',$data); $this->display('Cadmin/feedback'); }