PHP code example of liuwave / think-filesystem-driver-cos

1. Go to this page and download the library: Download liuwave/think-filesystem-driver-cos 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/ */

    

liuwave / think-filesystem-driver-cos example snippets


//默认$file为单文件。$file为多文件时file为数组,需要进行遍历处理
$file=\request()->file('file');
$filesystem     = \think\facade\Filesystem::disk('cos');
$saveName       = $filesystem->putFile('/path/to/save/file', $file, 'md5');
$saveName       = str_replace('\\', '/', $saveName);
$fullName = \think\facade\Filesystem::getDiskConfig('cos', 'url').'/'.$saveName;