tecsin / yii2-elfinder
yii2 的 Elfinder 文件管理器
1.0.2
2017-05-03 11:53 UTC
Requires
This package is auto-updated.
Last update: 2024-08-29 04:40:34 UTC
README
yii2 的 Elfinder 文件管理器。支持本地文件系统、FTP,并在使用时通过 Flysystem 挂载 Google Drive。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist tecsin/yii2-elfinder "*"
或者
"tecsin/yii2-elfinder": "*"
将以下内容添加到您的 composer.json
文件的 require 部分中。
使用方法
扩展安装完成后,只需在代码中使用即可:
控制器
class AdminController extends Controller { public function actionUpload(){ $fileManager = new \tecsin\elfinder\FileManager(); $fileManager->_uploadPath = Yii::getAlias('@webroot').'/files/'; $fileManager->_uploadUrl = Yii::getAlias('@web').'/files/'; /*to mount Google Drive with flysystem starts. OPTIONAL*/ $fileManager->googleDrive = [ 'clientID' => 'xxxxxx', 'clientSecret' => 'xxxxxxx', 'refreshToken' => 'xxxxxx', 'useCache' => true //optional ]; /*to mount Google Drive ends*/ $fileManager->connector(); } /**to use only for file manager for web**/ public function actionFileManager() { return $this->render('file-manager'); } /**to use only for file browser (picker) for tinymce**/ public function actionFileBrowser(){ return $this->renderAjax('file-browser');//use ajax not to have a new site load in the file browser window } }
Web 端 elFinder 文件管理器
file-manager 行动视图文件
/** * @var array clientOptions the options for configuration. * @see https://github.com/elfinder/wiki For full list of configurable options. */ <?= \tecsin\elfinder\ElFinderWidget::widget([ 'id' => 'working', 'clientOptions' => [ 'url' => '/admin/upload' ] ]); ?>
用于 TinyMCE 的 elFinder 文件浏览器(选择器)
file-browser 行动视图文件
<?= \tecsin\elfinder\ElFinderWidget::widget([ 'id' => 'working', 'useWithTinyMCE' => true,//REQUIRED 'clientOptions' => [ 'url' => '/admin/upload' ] ]); ?>
欢迎通过报告错误或编码更多功能的方式做出贡献。