PHP完全自学手册(珍藏版) 中文pdf扫描版下载
public function index(){ Vendor('aliyun.autoload'); $ossconfig = C("ALI_OSS"); if($ossconfig['status']==1) { $bucket = $ossconfig['bucket']; $accessKeyId = $ossconfig['accessKeyId']; $accessKeySecret = $ossconfig['accessKeySecret']; $endpoint = $ossconfig['endpoint']; try { $client = new \OSS\OssClient($accessKeyId, $accessKeySecret, $endpoint); } catch (OssException $e) { print $e->getMessage(); } try { $prefix = "Public/css/common.css"; $filename = dirname(dirname(dirname(dirname(__FILE__)))).'/'.$prefix; $client->uploadFile($bucket, $prefix,$filename); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } } else { $this->error("功能未启用"); } }
aliyun目录
转载请注明:谷谷点程序 » php oss上传文件的方法