PHPackages                             mazpaijo/yii2-attachments-aws2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. mazpaijo/yii2-attachments-aws2

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

mazpaijo/yii2-attachments-aws2
==============================

Extension for file uploading and attaching to the models

02PHPCI failing

Since Jul 9Pushed 6y agoCompare

[ Source](https://github.com/mazpaijo/yii2-attachments-aws2)[ Packagist](https://packagist.org/packages/mazpaijo/yii2-attachments-aws2)[ RSS](/packages/mazpaijo-yii2-attachments-aws2/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Yii2 attachments-aws
====================

[](#yii2-attachments-aws)

[![Latest Stable Version](https://camo.githubusercontent.com/685f696ab165ed13be5c3e703395ca0bf93c9624ddec056771b43ac37a45e97d/68747470733a2f2f706f7365722e707567782e6f72672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f762f737461626c65)](https://packagist.org/packages/mazpaijo/yii2-attachments-aws2)[![License](https://camo.githubusercontent.com/2f09050b345dde581acffbea702d53063466a63b44f0138fc72130eb3298dc49/68747470733a2f2f706f7365722e707567782e6f72672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f6c6963656e7365)](https://packagist.org/packages/mazpaijo/yii2-attachments-aws2)[![Build Status](https://camo.githubusercontent.com/3d3238f3ab72ecade837ed096ef4c7966dd4dd67a36abada2badfb37db56908b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f6261646765732f6275696c642e706e673f623d7465737473)](https://scrutinizer-ci.com/g/mazpaijo/yii2-attachments-aws2/build-status/tests)[![Code Coverage](https://camo.githubusercontent.com/cde3eaea1c7405c3567cc5444be3e08978ffcb97dcc4c9ba0f7f30da81930c3a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f6261646765732f636f7665726167652e706e673f623d7465737473)](https://scrutinizer-ci.com/g/mazpaijo/yii2-attachments-aws2/?branch=tests)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ee78980ff8d8a2218c96e583c9fc0da08e3655fb2f462666533efb724e15d37e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f6261646765732f7175616c6974792d73636f72652e706e673f623d7465737473)](https://scrutinizer-ci.com/g/mazpaijo/yii2-attachments-aws2/?branch=tests)[![Total Downloads](https://camo.githubusercontent.com/be4b136a8a5f892f1f9bb7c35ac67b020bdc26a4db764601a070d2aea4249cbe/68747470733a2f2f706f7365722e707567782e6f72672f6d617a7061696a6f2f796969322d6174746163686d656e74732d617773322f646f776e6c6f616473)](https://packagist.org/packages/mazpaijo/yii2-attachments-aws2)

Extension for file uploading and attaching to the models

Demo
----

[](#demo)

You can see the demo on the [krajee](http://plugins.krajee.com/file-input/demo) website

Installation
------------

[](#installation)

1. The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

    Either run

    ```
    php composer.phar require mazpaijo/yii2-attachments-aws2 "~1.0.0"

    ```

    or add

    ```
    "mazpaijo/yii2-attachments-aws2": "~1.0.0"

    ```

    to the require section of your `composer.json` file.
2. Add module to `common/config/main.php`

    ```
    'modules' => [
    	...
    	'attachments-aws' => [
    		'class' => mazpaijo\attachmentsAws2\Module::className(),
    		'tempPath' => '@app/uploads/temp',
    		'storePath' => '@app/uploads/store',
    		'rules' => [ // Rules according to the FileValidator
    		    'maxFiles' => 10, // Allow to upload maximum 3 files, default to 3
    			'mimeTypes' => 'image/png', // Only png images
    			'maxSize' => 1024 * 1024 // 1 MB
    		],
    		'tableName' => '{{%attachments-aws}}' // Optional, default to 'attach_file'
    	]
    	...
    ]
    ```
3. Apply migrations

    ```
    	'controllerMap' => [
    	...
    	'migrate' => [
    		'class' => 'yii\console\controllers\MigrateController',
    		'migrationNamespaces' => [
    			'mazpaijo\attachmentsAws2\migrations',
    		],
    	],
    	...
    	],
    ```

    ```
    php yii migrate/up

    ```
4. Attach behavior to your model (be sure that your model has "id" property)

    ```
    public function behaviors()
    {
    	return [
    		...
    		'fileBehavior' => [
    			'class' => \mazpaijo\attachmentsAws2\behaviors\FileBehavior::className()
    		]
    		...
    	];
    }
    ```
5. Make sure that you have added `'enctype' => 'multipart/form-data'` to the ActiveForm options
6. Make sure that you specified `maxFiles` in module rules and `maxFileCount` on `AttachmentsInput` to the number that you want

Usage
-----

[](#usage)

1. In the `form.php` of your model add file input

    ```

    ```
2. Use widget to show all attachments-aws of the model in the `view.php`

    ```

    ```
3. (Deprecated) Add onclick action to your submit button that uploads all files before submitting form

    ```
