Connector configuration¶
PHP¶
Simple example of connector inclusion and passing options:
1 <?php
2
3 // Include connector
4 include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
5
6 $opts = array(
7 'root' => '/var/www/localhost/elfinder/files',
8 'URL' => 'http://localhost/elfinder/files',
9 'lang' => 'ru',
10 'debug' => false,
11 'arc' => '7za',
12 'fileURL' => false,
13 'imgLib' => 'mogrify',
14 'dotFiles' => true,
15 'dirSize' => true,
16 'uploadAllow' => array('image/png'),
17 'uploadDeny' => array('image', 'text'),
18 'uploadOrder' => 'deny,allow',
19 'disabled' => array('edit', 'rename'),
20 'tmbDir' => '_tmb',
21 'defaults' => array(
22 'read' => true,
23 'write' => true,
24 'rm' => true
25 ),
26 );
27
28 $fm = new elFinder($opts);
29 $fm->run();
30
31 ?>
More detailed see source:src/connectors/php/connector.php
Options¶
| Parameter | Type | Description |
|---|---|---|
| root | String | Path to root directory. Required parameter |
| URL | String | URL of root directory. Required parameter |
| rootAlias | String | Alias for root directory |
| disabled | Array | List of disabled commands |
| dotFiles | Boolean | Show dot files. Default: true |
| dirSize | Boolean | Calculate directory sizes |
| fileMode | Octal | mode for new files |
| dirMode | Octal | mode for new directories |
| mimeDetect | String | MIME-type detection method (possible values: finfo, php, linux (file -ib), bsd (file -Ib), internal (based on file extensions)) |
| uploadAllow | Array | List of mime-types allowed to upload. Can be set exactly image/jpeg or to group application |
| uploadDeny | Array | List of mime-types disallowed to upload |
| uploadOrder | String | Order of upload rules execution. allow,deny only what is allowed, except what is disallowed (AND). deny,allow what is not disallowed or allowed (OR) |
| imgLib | String | Library for thumbnail creation (possible values: imagick, mogrify, gd). If not set will try detect automatically |
| tmbDir | String | Thumbnail direcroty. If not set thumbnails will be disabled |
| tmbCleanProb | Integer | How often to clean thumbnails. Possible values: from 0 to 200. 0 - never, 200 - on each client init request |
| tmbAtOnce | Integer | How many thumbnails to create per background request. Default: 5 |
| tmbSize | Integer | Thumbnail size in pixels |
| fileURL | Boolean | Show real URLs to files in client. Default: true |
| dateFormat | String | Time format. Default: j M Y H:i |
| logger | Object | Object-logger |
| defaults | Array | Default access for files/directories. Default: array( 'read' => true, 'write' => true, 'rm' => true ) |
| perms | Array | Permission for files/directories. More information on this page |
| archiveMimes | Array | List of file archives allowed to create. If not set will allow all detected archvies |
| archivers | Array | Information about archivers. If not set will try detect all available |
| debug | Boolean | Send debug information to client |
File upload¶
File upload allowance is controlled by MIME-type. It works the same as Access Control in Apache web-server.
Example:
1. Types not set in uploadAllow won't be upload. Allow upload all text files, except RTF and allow XML
1 'uploadAllow' => array('text', 'application/xml'),
2 'uploadDeny' => array('text/rtf'),
3 'uploadOrder' => 'allow,deny'
2. Deny all application upload except XML
1 'uploadAllow' => array('application/xml'),
2 'uploadDeny' => array('application'),
3 'uploadOrder' => 'deny,allow'
3. Also you can use special key all. Deny everything except images and flash
1 'uploadAllow' => array('image', 'application/x-shockwave-flash'),
2 'uploadDeny' => array('all'),
3 'uploadOrder' => 'deny,allow'
Access control¶
Default access to files/directories is controlled by option defaults
1 'defaults' => array(
2 'read' => true,
3 'write' => true,
4 'rm' => true
5 )
Individual file/directory access rules controlled by perms option which contains array. Keys of array are regular expressions for paths to files/directories, values are arrays of permissions.
Examples:
1. Disallow delete jpeg/png/gif:
1 'perms' => array(
2 '/\.(jpg|gif|png)$/i' => array(
3 'read' => true,
4 'write' => true,
5 'rm' => false
6 )
7 )
2. Disallow write to text files (also you won't be able to rename them):
1 'perms' => array(
2 '/\.(txt|html|php|py|pl|sh|xml)$/i' => array(
3 'read' => true,
4 'write' => false,
5 'rm' => true
6 )
7 )
3. User directory. Read - all, write and delete only in personal directory:
1 'defaults' => array(
2 'read' => true,
3 'write' => false,
4 'rm' => false
5 ),
6 'perms' => array(
7 '/^user_dir\/.*/' => array(
8 'read' => true,
9 'write' => true,
10 'rm' => true
11 )
12 )
Disable commands¶
Option disabled allows to turn off almost any command, except base ones needed for normal work of file manager.
Example:
Disable renaming all files and editing text files:
1 disabled => array('rename', 'edit')
Python¶
Options (python)¶
| Parameter | Type | Default value | Description |
|---|---|---|---|
| root | String | '' | Path to root directory. Required parameter |
| URL | String | '' | URL of root directory. Required parameter |
| rootAlias | String | 'Home' | Alias for root directory |
| fileURL | Boolean | True | Show real URLs to files in client |
| dotFiles | Boolean | False | Show dot files |
| dirSize | Boolean | True | Calculate directory sizes |
| fileMode | Octal | 0644 | mode for new files |
| dirMode | Octal | 0755 | mode for new directories |
| imgLib | String | 'auto' | Image library for thumbnails creation, False - disable |
| tmbDir | String | '.tmb' | Thumbnail directory, if not set thumbnails will be disabled |
| tmbAtOnce | Integer | 5 | ow many thumbnails to create per background request |
| tmbSize | Integer | 48 | Thumbnail size in pixels |
| uploadMaxSize | Integer | 256 | Max upload size |
| uploadAllow | List | [] | List of mime-types allowed to upload. Can be set exactly image/jpeg or to group application |
| uploadDeny | List | [] | List of mime-types disallowed to upload |
| uploadOrder | List | ['deny', 'allow'] | Order of upload rules execution. ['allow','deny'] - only what is allowed, except what is disallowed (AND), ['deny', 'allow'] - what is not disallowed or allowed (OR) |
| defaults | Dict | { 'read': True, 'write': True, 'rm': True } | Default access for files/directories |
| perms | Dict | {} | Permissions for individual files/directories |
| archiveMimes | Dict | {} | List of file archives allowed to create. If not set will allow all detected archives |
| archivers | Dict | {} | Information about archivers. If not set will try detect all available |
| disabled | List | [] | List of disabled commands |
| debug | Boolean | False | Send debug information to client |
Example (python)¶
Python-connector configuration is similar to php-connector, where you can get more detailed examples. Only differences are languages syntax and some data types used in options.
1 #!/usr/bin/env python
2
3 import elFinder
4
5 elFinder.connector({
6 'root': '/Users/troex/Sites/git/elfinder/files',
7 'URL': 'http://localhost/~troex/git/elfinder/files',
8 'debug': True, # send debug information
9 'dirSize': True, # calculate directory sizes
10 'dotFiles': True, # show files beginning with dot
11 'perms': {
12 '^/upload/.*': { # you can only upload into this directory
13 'read': False,
14 'write': False,
15 'rm': False
16 },
17 'backup': { # restrict any data changes
18 'read': True,
19 'write': False,
20 'rm': False
21 },
22 '^/secure': { # no access to this directory
23 'read': False,
24 'write': False,
25 'rm': False
26 }
27 },
28 'uploadDeny': ['image', 'application'], # deny upload images and applications
29 'uploadAllow': ['image/png', 'image/jpeg'], # allow upload jpg and png
30 'uploadOrder': ['deny', 'allow']
31 }).run()