function upfile() { foreach($_FILES as $k=>$v) { if($_FILES[$k]['name'] == '') { unset($_FILES[$k]); } } if(count($_FILES)>0) { $uArr = $_SESSION['applyuser']; $upload_config = array( 'upload_path' => 'uploads/file/' . date ( 'Ym' ) . '/' . date ( 'd' ).'/', 'allowed_types' => 'jpg|jpeg|png|bmp|gif', 'max_size' => '1024', 'max_width' => '1024', 'max_height' => '1024', 'file_name' => time ().rand ( 100000, 999999 ), ); $this->load->library('upload'); mkdirs ( FCPATH.$upload_config ['upload_path'] ); $this->upload->initialize($upload_config); $imgArr = array(); foreach ($_FILES as $key => $value) { if(!empty($_FILES[$key])) { if ($this->upload->do_upload($key)) { $pathArr = $this->upload->data(); $imgArr[] = $_SERVER['HTTP_HOST'].'/'.$upload_config ['upload_path'].$pathArr['file_name']; } else { //上传失败 $rtn = $this->upload->display_errors(); } } } $imgArr = json_encode($imgArr); $id = $uArr['id']; $data['imgpath'] = $imgArr; $data['beforehand1'] = 1; $this->db->where('userid', $id); $this->db->update('mba_apply_user_apply', $data); redirect('apply/user/index'); //ajaxReturn($rtn, $info = '什么都没传', $status = 1, $type = 'JSON',$ser=''); } }
报错
error:The upload path does not appear to be valid. 服务器路径换成绝对路径
我的表单是这样的 此处略去。。。。。。