PHP code example of tntma / storage

1. Go to this page and download the library: Download tntma/storage 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/ */

    

tntma / storage example snippets


composer 

Tinywan\Storage\Storage::config(); // 初始化。 默认为本地存储:local,阿里云:oss,腾讯云:cos,七牛:qiniu
$res = Tinywan\Storage\Storage::uploadFile();
var_dump(json_encode($res));

'local' => [
    'adapter' => \Tinywan\Storage\Adapter\LocalAdapter::class,
    'root' => public_path() . '/storage',
],

composer 

composer 

composer 

public function upload(Request $request)
{
    Storage::config(Storage::MODE_OSS, false); // 第一个参数为存储方式。第二个参数为是否本地文件(默认是)
    $base64 = $request->post('base64');
    $r = Storage::uploadBase64($base64,'png');
    var_dump($r);
}

Storage::config(Storage::MODE_OSS,false);
$localFile = runtime_path() . DIRECTORY_SEPARATOR . 'storage/webman.png';
$res = Storage::uploadServerFile($localFile);
regexp
vendor/bin/phpstan analyse src

vendor/bin/php-cs-fixer fix src