sevens/uploader-trait
Composer 安装命令:
composer require sevens/uploader-trait
包简介
A library for file upload in PHP.
README 文档
README
- It is part of the libraries used on the altvel framework project but can be used
in any applicable file upload scenario.
- File Uploader a.k.a uploader-trait is developed by Elisha Temiloluwa a.k.a TemmyScope.
- Developed to make easier the routine of file upload on traditional file servers.
- Install using composer
composer require sevens/uploader-trait
Usage: Implementating & Extending
There are two ways to use this library in your project
- One way would be to call the Uploader constructor
use Seven\File\Uploader; $uploader = new Uploader( string $destination = __DIR__.'/cdn', array $allowedTypes = [ 'jpg' => 'image/jpeg', 'png' => 'image/png' ], int $sizeLimit = 5024768 ); $uploader->upload('image');
- Another way would be to extend the Uploader Class and provide the necessary properties
***If you don't provide the necessary properties, default values have already being provided in the Uploader Class ***
use Seven\File\Uploader; class FileUploader extends Uploader{ protected $destination = __DIR__.'/cdn'; protected $allowedTypes = [ 'jpg' => 'image/jpeg', 'png' => 'image/png' ]; protected $sizeLimit = 5024768; }
Usage: Calling Methods
There are a couple useful methods to use in this library
$file = new FileUploader();
- Upload $_FILES['image']
$file->upload('image');
- To get uploaded file name only
$file->name()
- To get uploaded file address, containing file address and name
$file->fullName();
- To get uploaded file type
$file->type();
- To get uploaded status; returns True if upload was successful
$file->status();
- To get error message; it would be empty if upload status is true
$file->statusMessage();
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-07