douhuitan5863 2016-05-04 15:26
浏览 162
已采纳

ElFinder与CodeIgniter | 无法连接到后端

I'm having problems using for the first time ElFinder with CodeIgniter. I've followed the installation wiki but i'm getting the following error "Unable to connect to backend". Can someone help me? I'm lost.

 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

This is my Elfinder_lib.php file

> <?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); }

Part of my 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();

and the jQuery function that call the div container:

$(function() {
        var elf = $('#elfinder').elfinder({
            // lang: 'ru',             // language (OPTIONAL)
            url : 'elfinder/connector.php'  // connector URL (REQUIRED)
        }).elfinder('instance');          
        0 

2 条回答 默认 最新

  • douxia5179 2016-05-04 19:02
    关注

    I can see that you maybe need to modify some parts if your Elfinder_lib.php is in application/libraries and all your Elfinder files to

    <?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();   
    

    in your controller.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');          
        
    本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?
    按下Enter换行,Ctrl+Enter发表内容
  • doubian19900911 2017-07-18 17:34
    关注

    Maybe you forgot to disable CSRF Protection in config.php file. Edit config.php file in config folder :

    $config['csrf_protection']  = TRUE;
    
    $config['csrf_protection']  = FALSE;
        
    本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?
    按下Enter换行,Ctrl+Enter发表内容
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 psychopy(python为基础的)中引入cmd 不知道怎么去做关于前端电子请柬 Ubuntu22.04打开是tty界面。提示OOM 存储过程或函数中的结果集类型变量如何使用。 关于海信电视聚好看安装应用的问题 vue引入sdk后的回调问题 求一个智能家居控制的代码 ad软件 pcb布线pcb规则约束编辑器where the object matpcb布线pcb规则约束编辑器where the object matchs怎么没有+15v只有no net