| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Img extends Admin_Controller {
 
-     function __construct(){
 
-         parent::__construct();
 
- 		$this->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'))
 
-         {
 
- 			$data = $this->upload->data();
 
- 			// 获取原文件名和文件后缀
 
-             $file_name = $data['file_name'];
 
-             $file_ext = strtolower($data['file_ext']); // 将后缀变为小写
 
-             // 生成新的文件名
 
-              $new_file_name = $data['raw_name'] . $file_ext;
 
-             // 重命名文件
 
-             rename($data['full_path'], $data['file_path'] . $new_file_name);
 
- 			$full_path = $dir.$new_file_name;
 
-             echo json_encode(array('ok'=>1,'lx'=>$file_ext,'filename'=>$full_path));
 
-         }
 
- 		else
 
- 		{
 
- 			$cw = str_replace(array('<p>','</p>'),'',$this->upload->display_errors());
 
- 			echo json_encode(array('msg'=>$cw));
 
- 		}
 
-     }
 
- 	//编辑器上传图
 
- 	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);  
 
- 	}
 
- }
 
 
  |