文档
运行环境
PHP > 5.3
cURL
安装
composer require aliyuncs/oss-sdk-php
示例
<?php
use OSS\OssClient;
use OSS\Core\OssException;
// 阿里云账号AccessKey
$accessKeyId = "yourAccessKeyId";
$accessKeySecret = "yourAccessKeySecret";
$endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
$bucket = "examplebucket";
$host = "https://examplebucket.oss-cn-hangzhou.aliyuncs.com"
// 填写Object完整路径
$object = "exampledir/exampleobject.txt";
// 填写本地文件的完整路径
$filePath = "D:\\localpath\\examplefile.txt";
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->uploadFile($bucket, $object, $filePath);
$url = "${
$host}/${
$object}";
echo $url;