/**
  *上传
  */
 public function action_add()
 {
     //$this->checklogin();
     //$this->checkSpace();
     // 图片分类列表
     $uid = (int) $this->getQuery('uid', @$this->auth['uid']);
     $cate = new Category();
     $this->template->cate_list = $cate_list = $cate->getCates($uid);
     $user = ORM::factory('user')->where('uid', '=', $uid)->find();
     if ((int) $user->uid > 0) {
         if ($user->check_expire($uid)) {
             $this->show_message('您的帐号已过期或空间不足,请续费或完成积分任务,再进行操作');
             die;
         }
         if ($user->check_space($uid)) {
             $this->show_message('您的帐号已过期或空间不足,请续费或完成积分任务,再进行操作');
             die;
         }
         $cate_id = (int) $this->getQuery('cate_id');
         $img = ORM::factory('img');
         if (!empty($_FILES)) {
             // 取得硬盘目录
             $disks = ORM::factory('img_disk')->where('is_use', '=', 1)->find();
             //图片保存目录
             $save_dir = ORM::factory('user', $uid)->save_dir;
             $savePath = DOCROOT . '' . $disks->disk_name . '/' . $save_dir . '/';
             $upload = new Upload();
             $upload->set_path($savePath);
             $result = $upload->save($_FILES['Filedata']);
             $img->picname = $result['saveName'];
             $img->filename = $result['name'];
             $img->filesize = $result['size'];
             $img->userid = $uid;
             $custom = pathinfo($result['name']);
             $img->custom_name = $custom['filename'];
             $img->disk_id = $disks->disk_domain;
             $img->cate_id = $cate_id;
             $img->disk_name = $disks->disk_name . '/' . $save_dir;
             $img->save();
             $picname = $savePath . $result['saveName'];
             $this->thumb->create($picname, 130, 130);
             // 统计数据
         }
     } else {
         $links[] = array('text' => '去登录', 'href' => '/user/login?forward=' . urlencode($_SERVER['REQUEST_URI']));
         $this->show_message('你尚未登录,请登录后再进行操作。。。', 0, $links);
         die;
     }
 }