Skip to content

Connector configuration options

Gula Andrij edited this page Sep 12, 2016 · 34 revisions

This is a list of the available options for elFinder connector (PHP part), along with their default values. Options are specified by passing an array with certain keys as first argument to elFinder() class constructor. Example:

<?php

$opts = array(
    'locale' => '',
    'roots'  => array(
        array(
            'driver' => 'LocalFileSystem',
            'path'   => '/path/to/files/',
            'URL'    => 'http://localhost/to/files/'
        )
    )
);

// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();

In the example above we run elFinder using default wrapper elFinderConnector.

Main options

locale

Set locale. Currently only UTF-8 locales are supported. Passed to setLocale PHP function.

Data type: string
Default value: 'en_US.UTF-8'

debug

Send debug to client.

Data type: boolean
Default value: false

bind

Bind callbacks for user actions, similar to jQuery .bind(). Accepts array(key => value) pairs where:
key is a space separated list of actions to bind to;
value is a string with function name to call
OR
value is array($instance, 'method') where $instance is instance of your callback class and method if a name of a function to call (in call $instance->method(...)).

Callback will be called with next parameters $cmd, $result, $args, $elfinder. If the callback return true the client will sync (refresh).

Data type: array
Default value: array()
Example:

<?php

/**
 * Simple callback catcher
 *
 * @param  string   $cmd       command name
 * @param  array    $result    command result
 * @param  array    $args      command arguments from client
 * @param  object   $elfinder  elFinder instance
 * @return void|true
 **/
public function mySimpleCallback($cmd, $result, $args, $elfinder) {
    // do something here
}

$opts = array(
    'bind' => array(
        'mkdir mkfile rename duplicate upload rm paste' => 'mySimpleCallback'
    ),
    'roots' => array(...)
);

Logging example

roots

Array of arrays with per root settings. This is the only required option.
Multiple Roots

Data type: array
Default value: array()
Example:

<?php

$opts = array(
    'roots'  => array(
        array(
            'driver' => 'LocalFileSystem',
            'path'   => '/path/to/files/',
            'URL'    => 'http://localhost/to/files/'
        ),
        array(
            'driver' => 'MySQL',
            'host'   => 'localhost',
            'user'   => 'eluser',
            'pass'   => 'elpass',
            'db'     => 'elfinder',
            'path'   => 1,
        ),
        array(
            'driver' => 'FTP',
            'host'   => '192.168.1.1',
            'user'   => 'eluser',
            'pass'   => 'elpass',
            'path'   => '/'
        )
    )
);

See more options below

Root options

  • driver - Volume driver
  • path - Root directory path
  • startPath - Open this path on initial request instead of root path
  • URL - URL that points to path directory (also called 'root URL')
  • alias - Root path alias for volume root
  • mimeDetect - Method to detect files mimetypes
  • mimefile - Path to alternative mime types file
  • imgLib - Image manipulations library
  • tmbPath - Directory for thumbnails
  • tmbPathMode - Umask for thumbnails dir creation
  • tmbURL - URL for thumbnails directory set in tmbPath
  • tmbSize - Thumbnails size in pixels
  • tmbCrop - Crop thumbnails to fit tmbSize
  • tmbBgColor - Thumbnails background color (hex #rrggbb or transparent)
  • copyOverwrite - Replace files on paste or give new names to pasted files
  • copyJoin - Merge new and old content on paste
  • copyFrom - Allow to copy from this volume to other ones
  • copyTo - Allow to copy from other volumes to this one
  • uploadOverwrite - Replace files with the same name on upload or give them new names
  • uploadAllow - Mimetypes allowed to upload
  • uploadDeny - Mimetypes not allowed to upload
  • uploadOrder - Order to proccess uploadAllow and uploadDeny options
  • uploadMaxSize - Maximum upload file size
  • defaults - Default file/directory permissions
  • attributes - File permission attributes
  • acceptedName - Validate new file name regex or function
  • accessControl - Function or class instance method to control files permissions
  • accessControlData - Data that will be passet to access control method
  • disabled - List of commands disabled on this root
  • treeDeep - How many subdir levels return per request
  • checkSubfolders - Check children directories for other directories in it
  • separator - Directory separator
  • dateFormat - File modification date format
  • timeFormat - File modification time format
  • cryptLib - Library to crypt/uncrypt files names (not implemented yet)
  • archiveMimes - Allowed archive's mimetypes to create
  • archivers - Manual config for archivers
  • quarantine - Temporary directory for extracting archives (LocalFileSystem volume only)

General usage example

<?php

$opts = array(
    'roots'  => array(
        array(
            'driver'     => 'LocalFileSystem',
            'path'       => '/path/to/files/',
            'startPath'  => '/path/to/files/test',
            'URL'        => 'http://localhost/to/files/',
            'alias'      => 'Home',
            'mimeDetect' => 'internal',
            'imgLib'     => 'gd',
            'tmbPath'    => 'thumbnails',
            'tmbCrop'    => false,
            'defaults'   => array('read' => false, 'write' => true),
            'attributes' => array(
                array( // hide readmes
                    'pattern' => '/README/',
                    'read' => false,
                    'write' => false,
                    'hidden' => true,
                    'locked' => false
                ),
                array( // restrict access to png files
                    'pattern' => '/\.png$/',
                    'write' => false,
                    'locked' => true
                )
            ),
        ),
        array( // another root
            'driver' => 'MySQL',
            'host'   => 'localhost',
            'user'   => 'eluser',
            'pass'   => 'elpass',
            'db'     => 'elfinder',
            'path'   => 1,
        )
    )
);

driver

Volume driver. Set storage engine for current root, can be one of LocalFileSystem, MySQL, FTP

Data type: string
Default value: 'LocalFileSystem'

path

Root directory path

Data type: string
Default value: ''

startPath

Open this path on initial request instead of root path

Notice: In order to validate this option by a multi-route, you have to set a value only to the volume which applies this option.

Data type: string
Default value: ''

URL

URL that points to path directory (also called 'root URL'). If not set client will not see full path to files (replacement for old fileURL option), also all files downloads will be handled by connector.
Disable real file path from being shown

Data type: string
Default value: ''

alias

Root path alias for volume root. If not set will use directory name of path. Warning: when this option is set it will also rewrite return path for getFileCallback

Data type: string
Default value: ''

mimeDetect

Method to detect files mimetypes. Can be auto, internal, finfo, mime_content_type

Data type: string
Default value: 'auto'

mimefile

Path to alternative mime types file. Only used when mimeDetect set to internal. If not set will use default mime.types

Data type: string
Default value: ''

imgLib

Image manipulations library. Can be auto, imagick or gd

Data type: string
Default value: 'auto'

tmbPath

Directory for thumbnails

Data type: string
Default value: '.tmb'

tmbPathMode

Umask for thumbnails dir creation. Will be removed in future

Data type: octal
Default value: 0777

tmbURL

URL for thumbnails directory set in tmbPath. Set it only if you want to store thumbnails outside root directory

Data type: string
Default value: ''

tmbSize

Thumbnails size in pixels. Thumbnails are square

Data type: integer
Default value: 48

tmbCrop

Crop thumbnails to fit tmbSize. true - resize and crop, false - scale image to fit thumbnail size

Data type: boolean
Default value: true

tmbBgColor

Thumbnails background color (hex #rrggbb or transparent). Also used when rotating images

Data type: string
Default value: '#ffffff'

copyOverwrite

Replace files on paste or give new names to pasted files. true - old file will be replaced with new one, false - new file get name - original_name-number.ext

Data type: boolean
Default value: true

copyJoin

Merge new and old content on paste. true - join new and old directories content, false - replace old directories with new ones

Data type: boolean
Default value: true

copyFrom

Allow to copy from this volume to other ones

Data type: boolean
Default value: true

copyTo

Allow to copy from other volumes to this one

Data type: boolean
Default value: true

uploadOverwrite

Replace files with the same name on upload or give them new names. true - replace old files, false give new names like original_name-number.ext

Data type: boolean
Default value: true

uploadAllow

Mimetypes allowed to upload

Data type: array
Default value: array()
Example:

'uploadAllow' => array('image') # allow any images
'uploadAllow' => array('image/png', 'application/x-shockwave-flash') # allow png and flash

uploadDeny

Mimetypes not allowed to upload. Same values accepted as in uploadAllow

Data type: array
Default value: array()

uploadOrder

Order to proccess uploadAllow and uploadDeny options. Logic is the same as Apache web server options Allow, Deny, Order http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order

Data type: array
Default value: array('deny', 'allow')

uploadMaxSize

Maximum upload file size. This size is per files. Can be set as number or string with unit 10M, 500K, 1G. Note you still have to configure PHP files upload limits.

Data type: integer|string
Default value: 0

defaults

Default file/directory permissions. Setting hidden, locked here - take no effect

Data type: array
Default value: 'defaults' => array('read' => true, 'write' => true)

attributes

File permission attributes. Simple file permissions control

Data type: array
Default value: array()

acceptedName

Validate new file name regex or function

Data type: string
Default value: '/^[^\.].*/'
Example:

function validName($name) {
    return strpos($name, '.') !== 0;
}

// later in root options
'acceptedName' => 'validName'

accessControl

Function or class instance method to control files permissions. This works similar to bind option

Data type: string|array|null
Default value: null

accessControlData

Data that will be passet to access control method

Data type: undefined
Default value: null

disabled

List of commands disabled on this root

Data type: array
Default value: array()

treeDeep

How many subdirs levels return per request

Data type: integer
Default value: 1

checkSubfolders

Check children directories for other directories in it. true every folder will be check for children folders, false all folders will be marked as having subfolders

Data type: boolean
Default value: true

separator

Directory separator. Required by client to show correct file paths

Data type: string
Default value: DIRECTORY_SEPARATOR

dateFormat

File modification date format. This value is passed to PHP date() function

Data type: string
Default value: 'j M Y H:i'

timeFormat

File modification time format

Data type: string
Default value: 'H:i'

cryptLib

Library to crypt/uncrypt files names (not implemented yet)

Data type: undefined
Default value: undefined

archiveMimes

Allowed archive's mimetypes to create. Leave empty for all available types

Data type: array
Default value: array()

archivers

Manual config for archivers. Leave empty for auto detect

Data type: array
Default value: array()

quarantine

Temporary directory for archive file extracting. This option only uses the LocalFileSystem volume driver.

We recommend to set a path outside the document root.

Data type: string
Default value: path/.quarantine

Volume driver specific options

MySQL

array(
    'driver'        => 'MySQL',
    'host'          => 'localhost',
    'socket'        => '/tmp/mysql.sock',
    'user'          => 'eluser',
    'pass'          => 'elpass',
    'db'            => 'elfinder',
    'files_table'   => 'elfinder_file',
    'path'          => 1,
    'tmpPath'       => '/tmp'
)

FTP

array(
    'driver'        => 'FTP',
    'host'          => 'localhost',
    'user'          => 'eluser',
    'pass'          => 'elpass',
    'port'          => 21,
    'mode'          => 'passive',
    'path'          => '/',
    'timeout'       => 10,
    'owner'         => true,
    'tmbPath'       => '',
    'tmpPath'       => '',
    'dirMode'       => 0755,
    'fileMode'      => 0644
)
Clone this wiki locally