2017 © Pedro Peláez
 

yii2-extension yii2-file-upload-module

This is Yii2 extension for the upload files

image

lav45/yii2-file-upload-module

This is Yii2 extension for the upload files

  • Wednesday, March 14, 2018
  • by LAV45
  • Repository
  • 1 Watchers
  • 1 Stars
  • 493 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

yii2-file-upload-module

This is a module for the Yii2 Framework which will help you upload files and access them from the browser., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

~$ composer require --prefer-dist lav45/yii2-file-upload-module

or add, (*4)

"lav45/yii2-file-upload-module": "1.0.*"

to the require section of your composer.json file., (*5)

Basic Usage:

Add path aliases and url to your file store in the main config You need to configure your web server to the @storageDir directory and specify @storageUrl, (*6)

return [
    'aliases' => [
        '@storageUrl' => 'https://cdn.site.com/storage',
    ],
    'components' => [
        'fs' => [
            'class' => creocoder\flysystem\LocalFilesystem::className(),
            'path' => '@common/cdn',
        ]
    ],
];

Add action to the main controller, (*7)

use lav45\fileUpload\UploadAction;

class PageController extends Controller
{
    public function actions()
    {
        return [
            'upload' => [
                'class' => UploadAction::className(),
            ],
        ];
    }
}

Need to add to your ActiveRecord model, (*8)

use lav45\fileUpload\UploadTrait;
use lav45\fileUpload\UploadBehavior;
use lav45\fileUpload\UploadInterface;

class Page extends ActiveRecord implements UploadInterface
{
    use UploadTrait;

    public function rules()
    {
        return [
            [['image'], 'string'],
        ];
    }

    public function behaviors()
    {
        return [
            [
                'class' => UploadBehavior::className(),
                'attribute' => 'image',
            ],
        ];
    }

    public function getUploadPath()
    {
        return '/page/' . $this->id;
    }
}

Need to add a field for uploading files, (*9)

/**
 * @var Page $model
 */

use lav45\fileUpload\widget\FileUpload;

$form = ActiveForm::begin();

echo $form->field($model, 'image')->widget(FileUpload::className());

ActiveForm::end();

Displays the uploaded file, (*10)

<?php
/**
 * @var Page $model
 */
 ?>

<img src="<?= $model->getAttributeUrl('image') ?>" alt="">

The Versions

14/03 2018

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/LAV45/yii2-file-upload-module

This is Yii2 extension for the upload files

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 upload widget behavior

14/03 2018

1.0.0.x-dev

1.0.0.9999999-dev https://github.com/LAV45/yii2-file-upload-module

This is Yii2 extension for the upload files

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 upload widget behavior

14/03 2018

dev-master

9999999-dev https://github.com/LAV45/yii2-file-upload-module

This is Yii2 extension for the upload files

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 upload widget behavior

14/03 2017

0.1.1

0.1.1.0 https://github.com/LAV45/yii2-file-upload-module

This is Yii2 extension for the upload files

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 upload widget behavior

07/03 2017

0.1.0

0.1.0.0 https://github.com/LAV45/yii2-file-upload-module

This is Yii2 extension for the upload files

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 upload widget behavior