initphp/upload
最新稳定版本:1.0
Composer 安装命令:
composer require initphp/upload
包简介
InitPHP Upload Library
README 文档
README
It is developed to upload files to local or remote server.
Installation
composer require initphp/upload
Usage
\InitPHP\Upload\File::setPost()
Returns a normalized Array<\InitPHP\Upload\File> from the array $_FILES with the specified $key.
\InitPHP\Upload\File::setPath()
Loads a specific file into the file object.
Local Adapter
use InitPHP\Upload\Upload; use InitPHP\Upload\File; $credentials = [ 'dir' => __DIR__ . '/uploads/', 'url' => 'https://example.com/uploads/', ]; $options = [ 'allowed_extensions' => [], 'allowed_mime_types' => [], 'allowed_max_size' => 0, ]; $adapter = new InitPHP\Upload\Adapters\LocalAdapter($credentials, $options); $upload = new Upload($adapter); foreach (File::setPost('files') as $file) { $upload->setFile($file) ->to(); }
FTP Adapter
use InitPHP\Upload\Upload; use InitPHP\Upload\File; $credentials = [ 'host' => 'ftp.example.com', 'port' => 21, 'username' => 'user', 'password' => '123456', 'timeout' => 90, 'url' => 'http://example.com/', ]; $options = [ 'allowed_extensions' => [], 'allowed_mime_types' => [], 'allowed_max_size' => 0, ]; $adapter = new InitPHP\Upload\Adapters\FTPAdapter($credentials, $options); $upload = new Upload($adapter); foreach (File::setPost('files') as $file) { $upload->setFile($file) ->to(); }
AWS S3 Adapter
use InitPHP\Upload\Upload; use InitPHP\Upload\File; $credentials = [ 'key' => '', 'secret_key' => '', 'region' => '', 'bucket' => '', 'ACL' => 'public-read', 'version' => 'latest', ]; $options = [ 'allowed_extensions' => [], 'allowed_mime_types' => [], 'allowed_max_size' => 0, ]; $adapter = new InitPHP\Upload\Adapters\S3Adapter($credentials, $options); $upload = new Upload($adapter); foreach (File::setPost('files') as $file) { $upload->setFile($file) ->to(); }
Credits
License
Copyright © 2023 MIT License
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-19