load->library('upload'); } public function _remap($arg) { if($arg == 'textimg') { $this->_textimg(); } else if($arg == 'thumb') { $this->_thumb(); } else { $this->_index(); } } //上传图片 public function _index() { $dir = '/data/img/'.date('Ymd',time()).'/'; $config['upload_path'] = '.'.$dir ; $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999); $config['allowed_types'] = '*'; $config['max_size'] = 51200; $this->load->library('upload', $config); $this->upload->initialize($config); if ($this->upload->do_upload('userfile')) { $full_path = $dir.$this->upload->data('file_name'); echo json_encode(array('ok'=>1,'lx'=>$this->upload->data('file_ext'),'filename'=>$full_path)); } else { echo json_encode(array('msg'=>$this->upload->display_errors())); } } //编辑器上传图 public function _textimg() { $dir = '/data/img/'.date('Ymd',time()).'/'; $config['upload_path'] = '.'.$dir ; $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999); $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 51200; $field_name = "upfile"; $this->load->library('upload', $config); $this->upload->initialize($config); if ($this->upload->do_upload($field_name)) { $name = $this->upload->data('file_name'); //重命名后的图片名称+后缀 $client_name = $this->upload->data('client_name');//提交的图片名称+后缀 $file_ext = $this->upload->data('file_ext');//图片后缀 $file_size = $this->upload->data('file_size');//图片大小 $full_path = $dir.$this->upload->data('file_name');//图片上传的完整路径+名称+后缀 echo json_encode(array('errno'=>0,'data'=>array('url'=>'http://a.wepolicy.cn'.$full_path))); } else { echo json_encode(array('errno'=>1,'data'=>array('message'=>$this->upload->display_errors()))); } } public function _thumb() { $this->load->library('thumb'); $test=new thumb(); $src = FCPATH.$this->input->get('src'); $w = $this->input->get('w'); $h = $this->input->get('h'); $a = $this->input->get('a'); $test->SetVar($src,'link'); $test->PRorate($src,$w,$h); } }