/** * 初始化 */ public static function getAliOss() { if (!self::$alioss) { self::$alioss = new ALIOSS(); //设置是否打开curl调试模式 self::$alioss->set_debug_mode(false); } return self::$alioss; }
/** * 文件上传 * * @return bool */ public function uploadAction() { header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); $sFrom = $this->getParam('from'); //上传来源,对应oss中的二级文件夹名 $aData = Oss_Index::uploadImage($sFrom); if (empty($aData)) { return $this->showMsg('图片上传失败', false); } return $this->showMsg($aData, true); }