Download the PHP package liv/yii2-file-kit without Composer
On this page you can find all versions of the php package liv/yii2-file-kit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download liv/yii2-file-kit
More information about liv/yii2-file-kit
Files in liv/yii2-file-kit
Package yii2-file-kit
Short Description Yii2 file upload and storage kit plus, add JCrop and resize
License BSD-3-Clause
Informations about the package yii2-file-kit
This kit 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
Demo
Since file kit is a part of yii2-starter-kit it's demo can be found in starter kit demo here.
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 Storage
to work with flysystem
.
- Create a builder class that implements
trntv\filekit\filesystem\FilesystemBuilderInterface
and implement methodbuild
which returns filesystem object Example:
Configuration:
Read more about flysystem at http://flysystem.thephpleague.com/
Then you can use it like this:
- Use third-party extensions,
creocoder/yii2-flysystem
for example, and provide a name of the filesystem component infilesystemComponent
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
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
All versions of yii2-file-kit with dependencies
yiisoft/yii2-jui Version ~2.0.0
league/url Version ~3.0
league/flysystem Version ~1.0
bower-asset/blueimp-file-upload Version ~9.7.0
bower-asset/blueimp-canvas-to-blob Version ^2.1
bower-asset/blueimp-load-image Version ^1.13
bower-asset/blueimp-tmpl Version ^2.5
bower-asset/jcrop Version ^2.0