图片上传腾讯云存储
function cosPub($path){ $cosClient = new Client( array( 'region' => 'ap-chengdu', 'credentials'=> array( 'secretId' => env('QCLOUD_COS_SECRET_ID'), 'secretKey' => env('QCLOUD_COS_SECRET_KEY') ) ) ); try { $bucket = ""; $key = '/houtai/' . md5(time()) . '.' . 'jpg'; $srcPath =$path; $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($srcPath, 'rb'))); $res = res(200, ['url'=>$result['ObjectURL']]); } catch (\Exception $e) { $res = res(403, [], '文件上传失败'); } return $res; }