t-kanstantsin/fileupload

文件上传和存储实用工具

v3.10.1 2019-01-04 11:58 UTC

README

易于控制的文件上传、存储和格式化小部件。

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage Software License

配置

功能齐全的配置示例

<?php
use \tkanstantsin\fileupload\FileManager;
use \tkanstantsin\fileupload\formatter\Image;
use \League\Flysystem\Adapter\Local as LocalFSAdapter;
use \League\Flysystem\Filesystem;

new FileManager([
    'uploadFS' => new Filesystem(new LocalFSAdapter(__DIR__ . '/tmp/upload', LOCK_EX, LocalFSAdapter::DISALLOW_LINKS)),
    'cacheFS' => new Filesystem(new LocalFSAdapter(__DIR__ . '/tmp/web', LOCK_EX, LocalFSAdapter::DISALLOW_LINKS)),

    'aliasArray' => [
        'attachment' => [
            'maxCount' => 1,
        ],
    ],
    'formatterConfigArray' => [
        'attachment-gallery' => [
            'class' => Image::class,
            'width' => 1920,
            'height' => 1080,
            'mode' => Image::RESIZE_INSET,
        ],
        'attachment-preview' => [
            'class' => Image::class,
            'width' => 300,
            'height' => 150,
            'mode' => Image::RESIZE_OUTBOUND,
        ],
    ],
]);

别名

name - 别名必须只包含拉丁字母、数字、连字符 (-) 和下划线

class

directory

maxSize

maxCount

multiple

hashMethod

cacheHashLength

filePathClosure

assetNameClosure