PHP code example of open20 / amos-attachments

1. Go to this page and download the library: Download open20/amos-attachments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

open20 / amos-attachments example snippets



'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'
    ],
],


'controllerMap' => [
    'attachments' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => '@amos_attachments/migrations'
    ],
],


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'],
    ]);
}
bash
php yii migrate/up --migrationPath=@vendor/open20/amos-attachments/src/migrations