You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TinyMCE、N1ED与CodeIgniter集成问题:无法整合文件管理器

Fixing Flmngr Integration in CodeIgniter 3

Let's break down the issues in your code and fix them step by step:

1. The Immediate Error: Calling Static Methods Outside Class Methods

In PHP, you can't execute function calls (even static ones) directly in the class body—they need to live inside a class method. Your FlmngrServer::flmngrRequest() call is sitting outside any method, which is why you're getting a syntax error.

2. Understanding :: in PHP

The :: operator is used to access static methods or properties of a class. Since flmngrRequest() is a static method provided by FlmngrServer, using :: is correct—but you just need to put that call inside a controller method that will handle the incoming request (like index()).

3. Proper Path Handling in CodeIgniter

Using relative paths like ../upload/... is risky in CodeIgniter, because the relative path changes depending on where your controller is located. Instead, use CodeIgniter's built-in constants for reliable absolute paths:

  • FCPATH: Points to your project's root directory (where index.php lives)
  • APPPATH: Points to the application/ folder

Corrected Controller Code

Here's the fixed version of your controller:

<?php defined('BASEPATH') OR exit('No direct script access allowed');

use EdSDK\FlmngrServer\FlmngrServer;

class MH_Admin_Filemanager extends MY_Admin_Core {

    function __construct() {
        parent::__construct();
    }

    // This method will handle the Flmngr API requests
    public function index() {
        // Use absolute paths with FCPATH to avoid relative path issues
        FlmngrServer::flmngrRequest([
            'dirFiles' => FCPATH . 'upload/filemanager_dir/files',
            'dirTmp' => FCPATH . 'upload/filemanager_dir/tmp',
            'dirCache' => FCPATH . 'upload/filemanager_dir/cache'
        ]);
    }
}

Additional Setup Steps

Don't forget these critical details:

  • Composer Autoload: Make sure CodeIgniter is loading Composer's autoloader. Open application/config/config.php and set:
    $config['composer_autoload'] = TRUE;
    
    This ensures the EdSDK\FlmngrServer namespace is recognized.
  • Directory Permissions: Ensure the upload/filemanager_dir/files, tmp, and cache directories have read/write permissions (typically 755 or 777, depending on your server setup). Without this, Flmngr won't be able to save files or process uploads.
  • Route Configuration: Add a route in application/config/routes.php to point Flmngr's frontend requests to this controller:
    $route['flmngr'] = 'MH_Admin_Filemanager';
    

How It Works Now

When Flmngr's frontend sends a request to your CodeIgniter app (to the /flmngr route), the index() method of your MH_Admin_Filemanager controller will run, call the static flmngrRequest() method with the correct absolute paths, and handle the file management operations.

内容的提问来源于stack exchange,提问作者spreaderman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 06:09:07