public function cosPub(){ //引入腾讯云的文件 autoload.php' $secretId = ""; //"云 API 密钥 SecretId"; $secretKey = ""; //"云 API 密钥 SecretKey"; $region = ""; //设置一个默认 $cosClient = new \Qcloud\Cos\Client( array( 'region' => $region, 'schema' => 'https', //协议头部,默认为http 'credentials'=> array( 'secretId' => $secretId , 'secretKey' => $secretKey) ) ); // 上传文件流 try { $bucket = ""; //存储桶名称 格式:BucketName-APPID $key = ''; //上传云上的路径 $srcPath ='';//本地文件绝对路径 $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($srcPath, 'rb'))); return $result; } catch (\Exception $e) { echo "$e\n"; } }
php上传图片(腾讯云对象存储)
最新推荐文章于 2025-03-23 00:33:52 发布