PHP code example of death_satan / thinkphp-ypyun-oss
1. Go to this page and download the library: Download death_satan/thinkphp-ypyun-oss 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/ */
//通过门面使用
think\facade\Filesystem::disk('ypyun')
//在控制器中通过注入使用
class TestControl{
public function Test(\think\Filesystem $filesystem)
{
$aliyun = $filesystem->disk('ypyun');
}
}
namespace app\controller;
use app\BaseController;
use app\Request;
use think\facade\Filesystem;
class Index extends BaseController
{
public function index(Request $request)
{
//获取上传文件
$file = $request->file('image');
//通过filesystem进行上传
$url = Filesystem::disk('ypyun')->putFile('images', $file);
if (!$url) new \exception('上传失败');
dd('上传成功,文件位置:' . $url);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.