Download the PHP package tpmanc/yii2-file-behavior without Composer
On this page you can find all versions of the php package tpmanc/yii2-file-behavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tpmanc/yii2-file-behavior
More information about tpmanc/yii2-file-behavior
Files in tpmanc/yii2-file-behavior
Package yii2-file-behavior
Short Description Yii2 file uploading
License BSD-3-Clause
Homepage https://github.com/tpmanc/yii2-file-behavior
Informations about the package yii2-file-behavior
yii2-file-behavior
Yii 2 file uploading
Install via Composer
Run the following command
or add
to the require section of your composer.json
file.
Migrations
Create migration by following command
Open the /path/to/migrations/m_xxxxxx_xxxxxx_images.php
file
and add following code to up()
method
Create model
Generate Active Record model for new image
and imageSize
tables
Configuring
Attach the behavior to your model class:
If file hash will be like "6e3c797abee0ff2803ef1f952f187d2f"
the file will be located in @upload/images/6e/3c/{id from image table}.jpg
To save several sizes of image add:
If file hash will be like "6e3c797abee0ff2803ef1f952f187d2f" - result 3 images:
-
@upload/images/original/6e/3c/{id from image table}.jpg
-
@upload/images/big/6e/3c/{id from image table}.jpg
@upload/images/small/6e/3c/{id from image table}.jpg
View file
Example of view file
Geting images
Get single image:
Get all images:
Get count
images:
Return false
when image does not exist:
For single image:
For all images: