delete($bucket, $key); return $res; } /** * 七牛上传 * @param $newName 上传到七牛的文件名称 * @param $filePath 文件路径 */ public function upQiNiuFile($newName,$filePath){ Vendor('Qiniu.autoload'); //读取七牛配置 $config = C('qiniu_storage'); $accessKey = $config['AccessKey']; $secretKey = $config['SecretKey']; //实例化鉴权对象 $auth = new Auth($accessKey,$secretKey); $bucket = $config['bucket']; //生成token $token = $auth->uploadToken($bucket); //实例化上传类 $uploadMgr = new UploadManager(); //上传附件 list($ret,$err) = $uploadMgr->putFile($token,$newName,$filePath); if($ret){ return $url = $config['domain'].'/'.$newName; }else{ return ''; } } }