Skip to content

serhatozles/yii2-elfinder

Repository files navigation

elFinder

Yii2 Elfinder

See: http://elfinder.org/

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist serhatozles/yii2-elfinder "dev-master"

or add

"serhatozles/yii2-elfinder": "dev-master"

to the require section of your composer.json file.

Usage

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

Add Main.php

'controllerMap' => [
    'elfinder' => [
	'class' => 'serhatozles\elfinder\Controller',
//	    'options' => [
////		'height' => 250,
////		'getFileCallback' => 'function(url) { alert(url); }',
//		'uiOptions' => [
//		    'toolbar' => [
//			['back', 'forward'],
//			['netmount'],
//			['upload'],
//			['open', 'download', 'getfile'],
//			['info'],
//			['quicklook'],
//			['rm'],
//			['edit', 'resize'],
//			['search'],
//			['view', 'sort'],
//			['help']
//		    ]
//		],
//		'contextmenu' => [
//		    'navbar' => ['open', '|', 'info'],
//		    'cwd' => ['reload', 'back', '|', 'upload', '|', 'sort', '|', 'info'],
//		    'files' => ['getfile', '|', 'open', 'quicklook', '|', 'download', '|', 'rm', '|', 'edit', 'resize', '|', 'info']
//		],
//		'onlyMimes' => ["image"],
//	    ]
    ]
//    'elfinder2' => [
//	'class' => 'serhatozles\elfinder\Controller',
//	...
//    ]
//    ...
],

View:

    echo \serhatozles\elfinder\elFinder::widget([
	'ajax' => Url::to(['site/elfinder']),
//	'controller' => 'elfinder2',
//	'height' => 270,
    ]); 

Controller Action:

    public $enableCsrfValidation = false;

    public function actionElfinder() {

	$elFinder = new \serhatozles\elfinder\elFinder;
	echo $elFinder->connector([
	    // 'debug' => true,
	    'roots' => [
		[
		    'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
		    'path' => Yii::getAlias('@webroot/files/'), // path to files (REQUIRED)
		    'URL' => Yii::getAlias('@web/files/'), // URL to files (REQUIRED)
		    'mimeDetect' => 'internal',
		    'onlyMimes' => ['image'],
		],
	    ]
	]);
    }

Releases

No releases published

Packages

No packages published