file('file'); $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/upload'; if(!file_exists($dir)){ //检查是否有该文件夹,如果没有就创建,并给予最高权限 mkdir($dir, 0700,true); } $ossClient = new OssClient(self::getOneValues('storage_oss_keyid'), self::getOneValues('storage_oss_secret'), self::getOneValues('storage_oss_endpoint')); $info = $file->move($dir); $newName = $info->getSaveName(); $storage_type = self::getOneValues('storage_type'); if ($storage_type == 'oss'){ $file_path = dirname($_SERVER['SCRIPT_FILENAME']) . "/upload/".$newName; $result = $ossClient->uploadFile(self::getOneValues('storage_oss_bucket'), $newName, $file_path); $data['url'] = $result['info']['url']; unlink($file_path); }elseif ($storage_type=='local'){ //压缩图片 //image_png_size_add(ROOT_PATH . 'public' . DS . 'uploads/images/'.$newName,ROOT_PATH . 'public' . DS . 'uploads/images/'.$newName); $data['url'] = 'http://'.$_SERVER['SERVER_NAME']."/upload/{$newName}"; } $this->success('上传成功',$data); } /** * @title 获取系统配置 * @desc 获取系统配置 * @url /api/Publics/config_info * @method POST * @tag 基础 * * @return name:designclassifi type:string desc:设计分类 * @return name:skillslabel type:string desc:技能标签 * @return name:goodtype type:string desc:擅长类型 * @return name:goodstyle type:string desc:擅长风格 * @return name:service_start_time type:string desc:服务时间开始 * @return name:service_end_time type:string desc:服务时间结束 **/ public function config_info(){ $array['designclassifi'] = explode(',',Config::get_values('designclassifi')); $array['skillslabel'] = explode(',',Config::get_values('skillslabel')); $array['goodtype'] = explode(',',Config::get_values('goodtype')); $array['goodstyle'] = explode(',',Config::get_values('goodstyle')); $array['service_start_time'] = Config::get_values('service_start_time'); $array['service_end_time'] = Config::get_values('service_end_time'); $this->success('成功',$array); } }