open20 / amos-attachments
Extension for file uploading and attaching to the models
Installs: 232
Dependents: 26
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Type:yii2-extension
Requires
- php: >=5.4.0
- ext-sockets: *
- bower-asset/jquery-cropper: ^1.0
- himiklab/yii2-colorbox-widget: *
- kartik-v/yii2-widget-fileinput: *
- open20/amos-core: ^1.32.0
- rosell-dk/webp-convert: ^2.9.2
- uitrick/yii2-widget-upload-crop: ^1.0.0
- xantios/mimey: ^2.2.0
- yiisoft/yii2-imagine: ^2.1.0
- yiisoft/yii2-jui: ^2.0
- yurkinx/yii2-image: *
Requires (Dev)
- phpunit/dbunit: ~1.0
- phpunit/phpunit: ~4.0
- dev-master
- 1.15.1
- 1.15.0
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.1
- 1.10.0
- 1.8.1
- 1.8.0
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.10
- 1.1.9
- dev-releases/1.15.1
- dev-releases/1.15.0
- dev-releases/1.12.2
- dev-releases/1.12.1
- dev-releases/1.12.0
- dev-releases/1.11.0
- dev-releases/1.10.1
- dev-releases/1.10.0
- dev-releases/1.8.1
- dev-releases/1.8.0
- dev-releases/1.7.0
- dev-releases/1.6.2
- dev-releases/1.6.1
- dev-releases/1.6.0
- dev-releases/1.5.0
- dev-releases/1.3.3
- dev-releases/1.3.2
- dev-releases/1.3.1
- dev-releases/1.3.0
This package is auto-updated.
Last update: 2024-12-20 19:21:11 UTC
README
Extension for file uploading and attaching to the models
Demo
You can see the demo on the krajee website
Installation
- The preferred way to install this extension is through composer.
Either run
composer require open20/amos-attachments
or add
"open20/amos-attachments": ">=1.0"
to the require section of your composer.json
file.
- Add module to your main config in common:
<?php 'aliases' => [ '@file' => dirname(__DIR__), ], 'modules' => [ 'attachments' => [ 'class' => 'open20\amos\attachments\FileModule', 'webDir' => 'files', 'tempPath' => '@common/uploads/temp', 'storePath' => '@common/uploads/store', // 'tableName' => '{{%attach_file}}' // Optional, default to 'attach_file' ], ],
Also, add these lines to your console config:
<?php 'controllerMap' => [ 'attachments' => [ 'class' => 'yii\console\controllers\MigrateController', 'migrationPath' => '@amos_attachments/migrations' ], ],
- Apply migrations
php yii migrate/up --migrationPath=@vendor/open20/amos-attachments/src/migrations
- Attach behavior to your model (be sure that your model has "id" property)
<?php use yii\helpers\ArrayHelper; /** * Adding the file behavior */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), [ 'fileBehavior' => [ 'class' => \file\behaviors\FileBehavior::className() ] ]); } /** * Add the new fields to the file behavior */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['my_field_multiple_files', 'my_field_single_file'], 'file'], ]); }
-
Make sure that you have added
'enctype' => 'multipart/form-data'
to the ActiveForm options -
Make sure that you specified
maxFiles
in module rules andmaxFileCount
onAttachmentsInput
to the number that you want -
Youre ready to use, See How