PHP code example of johnnycai / tp6-filesystem-cloud
1. Go to this page and download the library: Download johnnycai/tp6-filesystem-cloud library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
johnnycai / tp6-filesystem-cloud example snippets
composer
return [
"default" => "oss",
"disks" => [
"public" => [
"type" => "local",
"root" => ".",
"visibility" => "public",
"domain" => ""
],
// 阿里云配置
"oss" => [
"type" => "oss",
'prefix' => '',// 前缀,非必填
"accessKeyId" => "",
"accessKeySecret" => "",
"endpoint" => "",
"bucket" => "",
"domain" => ""
],
// 七牛云配置
"qiniu" => [
"type" => "qiniu",
"accessKey" => "",
"secretKey" => "",
"bucket" => "",
"domain" => ""
],
// 腾讯云配置
"cos" => [
"type" => "cos",
"region" => "ap-guangzhou",
"credentials" => [
"appId" => "",
"secretId" => "",
"secretKey" => ""
],
"bucket" => "",
"domain" => "",
"scheme" => "https",
'encrypt'=> false,
],
// 华为云配置
"obs" => [
"type" => "obs",
"accessKey" => "",
"secretKey" => "",
"endpoint" => "",
"bucket" => "",
"domain" => ""
],
]
];
$file = $this->request->file('file');
\think\facade\Filesystem::disk('oss')->putFile('upload', $file);
\think\facade\Filesystem::disk('oss')->delete($path);
\think\facade\Filesystem::disk('oss')->update($path);
\think\facade\Filesystem::disk('oss')->rename($path,$newpath);
\think\facade\Filesystem::disk('oss')->createDir($dirname);
\think\facade\Filesystem::disk('oss')->createDir($dirname);