Download the PHP package denoll/yii2-file-storage without Composer
On this page you can find all versions of the php package denoll/yii2-file-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download denoll/yii2-file-storage
More information about denoll/yii2-file-storage
Files in denoll/yii2-file-storage
Package yii2-file-storage
Short Description Yii2 file upload delete and storage
License BSD-3-Clause
Informations about the package yii2-file-storage
!!! This package creating Eugene Terentev https://github.com/trntv/yii2-file-kit.git. And I do not pretend to any copyrights. This package has been allocated separately only for their own needs !!!
This package is designed to automate routine processes of uploading files, their saving and storage.
It includes:
- File upload widget (based on Blueimp File Upload)
- Component for storing files (built on top of flysystem)
- Actions to download, delete, and view (download) files
- Behavior for saving files in the model and delete files when you delete a model
Here you can see list of available filesystem adapters
Demo
Since file kit is a part of yii2-starter-kit it's demo can be found in starter kit demo here.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
File Storage
To work with the File Kit you need to configure FileStorage first. This component is a layer of abstraction over the filesystem
- Its main task to take on the generation of a unique name for each file and trigger corresponding events.
There are several ways to configure denoll\filekit\Storage
to work with flysystem
.
Using Closure
Using filesystem builder
- Create a builder class that implements
denoll\filekit\filesystem\FilesystemBuilderInterface
and implement methodbuild
which returns filesystem object. Seeexamples/
- Add to your configuration:
Read more about flysystem at http://flysystem.thephpleague.com/
Using third-party extensions
-
Create filesystem component (example uses
creocoder/yii2-flysystem
) - Set filesystem component name in storage configuration:
Actions
File Kit contains several Actions to work with uploads.
Upload Action
Designed to save the file uploaded by the widget
See additional settings in the corresponding class
Delete Action
See additional settings in the corresponding class
View (Download) Action
See additional settings in the corresponding class
Upload Widget
Standalone usage
With ActiveForm
Upload Widget events
Upload widget trigger some of built-in blueimp events:
- start
- fail
- done
- always
You can use them directly or add your custom handlers in options:
UploadBehavior
This behavior is designed to save uploaded files in the corresponding relation.
Somewhere in model:
For multiple files
For single file upload
See additional settings in the corresponding class.
Validation
There are two ways you can perform validation over uploads. On the client side validation is performed by Blueimp File Upload. Here is documentation about available options.
On the server side validation is performed by [[yii\web\UploadAction]], where you can configure validation rules for [[yii\base\DynamicModel]] that will be used in validation process
Tips
Adding watermark
Install intervention/image
library
Edit your upload actions as so
All versions of yii2-file-storage with dependencies
yiisoft/yii2-jui Version ^2.0.0
league/flysystem Version ^1.0
bower-asset/blueimp-file-upload Version ^9.12.5