使用 CodeIgniter 的 ElFinder |无法连接到后端
ElFinder With CodeIgniter | Unable to connect to backend
我第一次将 ElFinder 与 CodeIgniter 一起使用时遇到问题。我已按照安装 wiki 进行操作,但出现以下错误 "Unable to connect to backend"。有人能帮我吗?我迷路了。
Here the error:
[enter image description here][1]
Here is an example of the code that i think is the key:
The elfinder url is: /home/optcenter/www/codeigniter/application/libraries
the upload forlder url:
home/optcenter/www/codeigniter/uploads
这是我的 Elfinder_lib.php 文件
> <?php if (!defined('BASEPATH')) exit('No direct script access
> allowed');
>
> include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderConnector.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinder.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderVolumeDriver.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderVolumeLocalFileSystem.class.php';
>
> class Elfinder_lib { public function __construct($opts) {
> $connector = new elFinderConnector(new elFinder($opts));
> $connector->run(); } }
Ex_controller.php
<?php function elfinder_init() { $this->load->helper('path'); $opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => set_realpath('../uploads/'),
'URL' => site_url('../uploads/') . '/'
// more elFinder options here
)
) ); $this->load->library('elfinder_lib', $opts); }
我的一部分conector.php
* * @param string $attr attribute name (read|write|locked|hidden)
* @param string $path file path relative to volume root directory started with directory separator * @return bool|null **/ function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot) ? !($attr
== 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : null; // else elFinder decide it itself }
// Documentation for connector options: // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options $opts = array( // 'debug' => true, 'roots' => array( array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => '../uploads/', // path to files (REQUIRED) 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED) 'uploadDeny' => array('all'), // All Mimetypes not allowed to upload 'uploadAllow' => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload 'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL) ) ) );
// run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run();
和调用div容器的jQuery函数:
$(function() {
var elf = $('#elfinder').elfinder({
// lang: 'ru', // language (OPTIONAL)
url : 'elfinder/connector.php' // connector URL (REQUIRED)
}).elfinder('instance');
});
我看到您可能需要修改一些部分
如果您的 Elfinder_lib.php 在 application/libraries 中并且您所有的 Elfinder 文件都在
<?php if (!defined('BASEPATH')) exit('No direct script access
allowed');
include_once 'elfinder/elFinderConnector.class.php';
include_once 'elfinder/elFinder.class.php';
include_once 'elfinder/elFinderVolumeDriver.class.php';
include_once 'elfinder/elFinderVolumeLocalFileSystem.class.php';
class Elfinder_lib{
public function __construct($opts){
//for this part see the documentation
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
}
}
在你的controller.php
<?php
function elfinder_init(){
$this->load->helper('path');
$opts = array(
//'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => set_realpath('./uploads/'),
'URL' => site_url('./uploads/') . '/'
//more elFinder options here
)
)
);
$this->load->library('elfinder_lib', $opts);
}
jQuery.jd
$(function() {
var elf = $('#elfinder').elfinder({
// lang: 'ru', // language (OPTIONAL)
url : 'ex_controller/elfinder_init' // connector URL (REQUIRED)
}).elfinder('instance');
});
可能您忘记在 config.php 文件中禁用 CSRF 保护。
编辑配置文件夹中的 config.php 文件:
$config['csrf_protection'] = TRUE;
收件人:
$config['csrf_protection'] = FALSE;
我第一次将 ElFinder 与 CodeIgniter 一起使用时遇到问题。我已按照安装 wiki 进行操作,但出现以下错误 "Unable to connect to backend"。有人能帮我吗?我迷路了。
Here the error:
[enter image description here][1]
Here is an example of the code that i think is the key:
The elfinder url is: /home/optcenter/www/codeigniter/application/libraries
the upload forlder url:
home/optcenter/www/codeigniter/uploads
这是我的 Elfinder_lib.php 文件
> <?php if (!defined('BASEPATH')) exit('No direct script access
> allowed');
>
> include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderConnector.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinder.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderVolumeDriver.class.php';
> include_once
> dirname(__FILE__).DIRECTORY_SEPARATOR.'elfinder/elFinderVolumeLocalFileSystem.class.php';
>
> class Elfinder_lib { public function __construct($opts) {
> $connector = new elFinderConnector(new elFinder($opts));
> $connector->run(); } }
Ex_controller.php
<?php function elfinder_init() { $this->load->helper('path'); $opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => set_realpath('../uploads/'),
'URL' => site_url('../uploads/') . '/'
// more elFinder options here
)
) ); $this->load->library('elfinder_lib', $opts); }
我的一部分conector.php
* * @param string $attr attribute name (read|write|locked|hidden)
* @param string $path file path relative to volume root directory started with directory separator * @return bool|null **/ function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot) ? !($attr
== 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : null; // else elFinder decide it itself }
// Documentation for connector options: // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options $opts = array( // 'debug' => true, 'roots' => array( array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => '../uploads/', // path to files (REQUIRED) 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED) 'uploadDeny' => array('all'), // All Mimetypes not allowed to upload 'uploadAllow' => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload 'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL) ) ) );
// run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run();
和调用div容器的jQuery函数:
$(function() {
var elf = $('#elfinder').elfinder({
// lang: 'ru', // language (OPTIONAL)
url : 'elfinder/connector.php' // connector URL (REQUIRED)
}).elfinder('instance');
});
我看到您可能需要修改一些部分 如果您的 Elfinder_lib.php 在 application/libraries 中并且您所有的 Elfinder 文件都在
<?php if (!defined('BASEPATH')) exit('No direct script access
allowed');
include_once 'elfinder/elFinderConnector.class.php';
include_once 'elfinder/elFinder.class.php';
include_once 'elfinder/elFinderVolumeDriver.class.php';
include_once 'elfinder/elFinderVolumeLocalFileSystem.class.php';
class Elfinder_lib{
public function __construct($opts){
//for this part see the documentation
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
}
}
在你的controller.php
<?php
function elfinder_init(){
$this->load->helper('path');
$opts = array(
//'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => set_realpath('./uploads/'),
'URL' => site_url('./uploads/') . '/'
//more elFinder options here
)
)
);
$this->load->library('elfinder_lib', $opts);
}
jQuery.jd
$(function() {
var elf = $('#elfinder').elfinder({
// lang: 'ru', // language (OPTIONAL)
url : 'ex_controller/elfinder_init' // connector URL (REQUIRED)
}).elfinder('instance');
});
可能您忘记在 config.php 文件中禁用 CSRF 保护。 编辑配置文件夹中的 config.php 文件:
$config['csrf_protection'] = TRUE;
收件人:
$config['csrf_protection'] = FALSE;