amirkh/yii2-file-manager

Upload and Manage Your Uploaded File in Yii2

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

Type:yii2-extension

dev-master 2018-10-20 09:44 UTC

This package is auto-updated.

Last update: 2024-04-20 21:31:16 UTC


README

Upload and Manage Your Uploaded File in Yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist amirkh/yii2-file-manager "*"

or add

"amirkh/yii2-file-manager": "*"

to the require section of your composer.json file.

Configure actions

For using file manager you must create and configure actions in SiteController or any Controller you like. See complete example with actions for list and upload:

<?php

namespace app\controllers;

use amirkhh\filemanager\actions\ListAction;
use amirkhh\filemanager\actions\UploadAction;
use yii\web\Controller;

class SiteController extends Controller
{
    public function actions()
    {
        return [
            'file-list' => [
                'class' => ListAction::class,
                'uploadDirectory' => 'uploads/files/',# Optional
                'pageSize' => 13,# Optional, For Pagination
            ],
            'file-upload' => [
                'class' => UploadAction::class,
                'uploadDirectory' => 'uploads/files/',# Optional
            ]
        ];
    }
}

Update your database schema

you need to do is updating your database schema by applying the migration:

$ php yii migrate/up --migrationPath=@vendor/amirkh/yii2-file-manager/migrations

Call widget

Once the extension is installed, simply use it in your code by :

<?= \amirkhh\filemanager\FileManager::widget(['form' => $form]) ?>