Skip to content
troex edited this page Apr 11, 2012 · 2 revisions

elFinder 1.x

This page contains all wiki information about elFinder 1.x version which is now deprecated

Install

jQuery and jQuery UI


<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-ui-1.7.2.custom.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="js/ui-themes/base/ui.all.css" type="text/css" media="screen" charset="utf-8">

Note: If you customize jQuery UI yourself, make sure you included next components: dialog, tabs, selectable, draggable, droppable, resizable

elFinder


<script src="js/elfinder.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/elfinder.css" type="text/css" media="screen" charset="utf-8">

Localization

Include language file if you need other language than English:


<script src="js/i18n/elfinder.ru.js" type="text/javascript" charset="utf-8"></script>

Initialize file manager

1. Using jQuery plugin:


<script type="text/javascript" charset="utf-8">
  $().ready(function(){
    $('#my-div').elfinder({
      url : 'connectors/php/connector.php',
      lang : 'ru'
    });
  });
</script>

2. Using constructor


<script type="text/javascript" charset="utf-8">
  $().ready(function(){
   var fm = new elFinder(document.getElementById('my-div'), {
     url : 'connectors/php/connector.php',
     lang : 'en'
   });
 });
</script>

Hotkeys

PC Mac Action
Ctrl+A Cmd+A Select all files
Ctrl+C Cmd+C Copy
Ctrl+X Cmd+X Cut
Ctrl+V Cmd+V Paste
Delete Cmd+Backspace Remove selected files
Ctrl+I Cmd+I Selected files or current directory info
Ctrl+N Cmd+N Create new directory
Ctrl+U Cmd+U Open upload files form
Enter Open selected file/folder
Space Open/close QuickLook window
Left or Up Select previous file
Righr or Down Select next file
Ctrl+Right Open selected file/folder
Ctrl+Left Return into previous folder
Shift+Arrows Set/Unset files selection
Drag Move
Darg+Shift Copy
Ctrl+Click Set/Unset files selection
F2 Rename

Client Configuration

elFinder can be configured in different ways:

1. during initialization:

$(selector).elfinder({
  option1: value1,
  option2: value2
})

2. before initialization and after elFinder files include (you can configure all options this way):


var opts = {
  option1: value1,
  option2: value2,
  option3: value3
}
elFinder.prototype.options = $.extend({}, elFinder.prototype.options, opts)

or just some options:

elFinder.prototype.options.option1 = value1;

Options

option type description
url String connector URL. The only required option
lang String Interface language. Require to include file js/i18n/elfinder.LANG.js, where LANG is two-letter language code, for example ru
cssClass String Additional CSS class for container
wrap Integer Number of symbols to show in a row when splitting long filenames in “icons” view. By default – 14. Do not split log filenames – 0
places String Folder name for “favorites”. Can be localized. By default – Places. You can set this to empty string "" to disable “favorites”
placesFirst Boolean Place “favorites” before file tree in navigation panel. By default – true
editorCallback Function or null Callback function for WYSIWYG editor (CKEditor, TinyMCE, elRTE etc…). This function will get argument (String) – URL of selected file
cutURL String Cut string from the URL when calling editorCallback, to cut base url use special value root
closeOnEditorCallback Boolean Close elFinder after calling editorCallback? By default – true. (useless for CKEditor, TinyMCE)
view String Default directory view. Possible values: icons, list. By default – icons
width Integer or String Width of file manager. By default not set, but takes value from CSS file source:src/css/elfinder.css
height Integer Height of file manager. By default not set, also can be set in CSS
disableShortcuts Boolean Disable shortcut keys (except arrows and space). By default – false
rememberLastDir Boolean Open last visited directory after page reload or after browser restart
cookie Object Set cookie (stores current view, last visited directory, “favorites”). By default – {expires : 30, domain : ‘’, path : ’/’, secure : false}
toolbar Array Groups of icons in toolbar. By default – all available buttons/commands. For more info visit docs
contextmenu Object Contents of context menu. By default – all available commands. For more info visit docs
dialog Object jQueryUI dialog options with which elFinder will be opened. If docked == true – elFinder will be opened with “undock” feature (make it dialog window)
docked Boolean Allow “undock” feature (can be refered in docks as “docked mode”)
autoReload Integer Amount of munites after which to update current directory contents. By default – 0 (disabled)

Toolbar

By default all buttons/commands are present in toolbar. If command is disabled in connector button wouldn’t show in toolbar, even if it is configured in client.

Option toolbar (Array) groups
Опция toolbar (Array) – two-dimensional array. First level – of icons, groups are visualy seperated in toolbar. Second level – buttons inside group. Groups of icons and icons in group will be shown in the same order as in config.

List of all available buttons: back, reload, open, select, quicklook, info, rename, copy, cut, paste, rm, mkdir, mkfile, upload, duplicate, edit, archive, extract, resize, icons, list, help.

Example:


$(selector).elfinder({
  toolbar : [
    ['back', 'reload'],
    ['select', 'open'],
    ['mkdir', 'mkfile', 'upload']
  ],
  ...
})

Context menu

Context menu can be redefined by option contextmenu (Object).

Example:


$(selector).elfinder({
  contextmenu : {
    // Commands that can be executed for current directory
    cwd : ['reload', 'delim', 'mkdir', 'mkfile', 'upload', 'delim', 'paste', 'delim', 'info'], 
    // Commands for only one selected file
    file : ['select', 'open', 'delim', 'copy', 'cut', 'rm', 'delim', 'duplicate', 'rename'], 
    // Coommands for group of selected files
    group : ['copy', 'cut', 'rm', 'delim', 'archive', 'extract', 'delim', 'info'] 
  },
  ...
}) 

Connector configuration

PHP

Simple example of connector inclusion and passing options:


<?php

// Include connector
include_once dirname(FILE).DIRECTORY_SEPARATOR.‘elFinder.class.php’;

$opts = array(
‘root’ => ‘/var/www/localhost/elfinder/files’,
URL’ => ‘http://localhost/elfinder/files’,
‘lang’ => ‘ru’,
‘debug’ => false,
‘arc’ => ‘7za’,
‘fileURL’ => false,
‘imgLib’ => ‘mogrify’,
‘dotFiles’ => true,
‘dirSize’ => true,
‘uploadAllow’ => array(‘image/png’),
‘uploadDeny’ => array(‘image’, ‘text’),
‘uploadOrder’ => ‘deny,allow’,
‘disabled’ => array(‘edit’, ‘rename’),
‘tmbDir’ => ‘_tmb’,
‘defaults’ => array(
‘read’ => true,
‘write’ => true,
‘rm’ => true
),
);

$fm = new elFinder($opts);
$fm→run();

?>

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


'uploadAllow'  => array('text', 'application/xml'),
'uploadDeny'   => array('text/rtf'),
'uploadOrder'  => 'allow,deny'

2. Deny all application upload except XML


'uploadAllow'  => array('application/xml'),
'uploadDeny'   => array('application'),
'uploadOrder'  => 'deny,allow'

3. Also you can use special key all. Deny everything except images and flash


'uploadAllow'  => array('image', 'application/x-shockwave-flash'),
'uploadDeny'   => array('all'),
'uploadOrder'  => 'deny,allow'

Access control

Default access to files/directories is controlled by option defaults


'defaults' => array(
   'read'  => true,
   'write' => true,
   'rm'    => true
)

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:


'perms' => array(
  '/\.(jpg|gif|png)$/i' => array(
    'read'  => true,
    'write' => true,
    'rm'    => false
  )
)

2. Disallow write to text files (also you won’t be able to rename them):


'perms' => array(
   '/\.(txt|html|php|py|pl|sh|xml)$/i' => array(
      'read'  => true,
      'write' => false,
      'rm'    => true
   )
)

3. User directory. Read – all, write and delete only in personal directory:


'defaults' => array(
   'read'  => true,
   'write' => false,
   'rm'    => false
),
'perms' => array(
   '/^user_dir\/.*/' => array(
      'read'  => true,
      'write' => true,
      'rm'    => true
   )
)

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:


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, where you can get more detailed examples. Only differences are languages syntax and some data types used in options.


#!/usr/bin/env python

import elFinder

elFinder.connector({
    'root': '/Users/troex/Sites/git/elfinder/files',
    'URL': 'http://localhost/~troex/git/elfinder/files',
    'debug': True,                   # send debug information
    'dirSize': True,                 # calculate directory sizes
    'dotFiles': True,                # show files beginning with dot
    'perms': {
        '^/upload/.*': {             # you can only upload into this directory
            'read': False,
            'write': False,
            'rm': False
        },
        'backup': {                  # restrict any data changes
            'read': True,
            'write': False,
            'rm': False
        },
        '^/secure': {                # no access to this directory
            'read': False,
            'write': False,
            'rm': False
        }
    },
    'uploadDeny': ['image', 'application'],      # deny upload images and applications
    'uploadAllow': ['image/png', 'image/jpeg'],  # allow upload jpg and png
    'uploadOrder': ['deny', 'allow']
}).run()

Integration with other products

elFinder designed in a such way that that it could easily integrated into existing solutions.

elRTE

During elRTE initialization pass function that will open file manager in dialog window and return editorCallback function, which accepts URL to file as only argument:


$('selector').elrte({
   // ... elrte options
   fmOpen : function(callback) {
      $('<div id="myelfinder" />').elfinder({
         url : 'connectors/php/connector.php',
         lang : 'ru',
         dialog : { width : 900, modal : true, title : 'Files' }, // open in dialog window
         closeOnEditorCallback : true, // close after file select
         editorCallback : callback     // pass callback to file manager
      })
   }
})

Attention: If you do not define id attribute – elFinder will not be able to remember last open directory and selected view, it also will result in unneeded cookie creation that can lead to max cookie per domain problem.

CKEditor

Dialog for link or image insertion opens in the same window but file manager in a new one:


CKEDITOR.replace('textarea_id', {
   filebrowserBrowseUrl : 'elfinder.html'
})

In elfinder.html include jQuery, jQueryUI, elFinder and after add:


$().ready(function() {
var funcNum = window.location.search.replace(/^.CKEditorFuncNum=(\d+).$/, “$1”);
var langCode = window.location.search.replace(/^.langCode=([a-z]{2}).$/, “$1”);

$(‘#finder’).elfinder({
url : ‘connectors/php/connector.php’,
lang : langCode,
editorCallback : function(url) {
window.opener.CKEDITOR.tools.callFunction(funcNum, url);
window.close();
}
})

})

TinyMCE

Dialog for link or image insertion and file manager open in new windows.
Create editor:


tinyMCE.init({
   // General options
   mode : "textareas",
   // ... any options
   file_browser_callback : function(field_name, url, type, win) {
      var w = window.open('http://localhost/absolute/url/to/elfinder.html', null, 'width=600,height=500');
      // Save required parameters in global variables of window (not the best solution, can offer better?)
      // else you can pass parameters using GET and than parse them in elfinder.html
      w.tinymceFileField = field_name;
      w.tinymceFileWin = win;
   }
})

In elfinder.html include jQuery, jQueryUI, elFinder and after add:


$('#finder').elfinder({
   url : 'connectors/php/connector.php',
   lang : 'ru',
   editorCallback : function(url) {
      window.tinymceFileWin.document.forms[0].elements[window.tinymceFileField].value = url;
      window.tinymceFileWin.focus();
      window.close();
   }
})

Drupal

Plugin homepage: http://drupal.org/project/elfinder
Download: http://sourceforge.net/projects/drupal-elfinder/

WordPress

Plugin homepage: http://wordpress.org/extend/plugins/wp-elfinder/

web2py

Homepage: http://code.google.com/p/elfinder-web2py/

Client-Server protocol API 1.x

Connector is server-side script (PHP, Python). Client is user-side script witch works in a browser (JavaScript). When user makes any actions with files client sends request to the server (connector) and gets response. Connector receive data from client using GET or POST (only when upload and edit) request. Connector always return JSON object to client.

Only always required parameter for connector is cmd – name of the command: http://localhost/connector.php?cmd=open

General parameters often used when sending request to connector:

  • current : (String) hash from the path of a current working directory
  • target : (String) hash from the path to a file that take action
  • targets : (Array) array of hashes of files/directories which take action

For any command request connector can send next parameters:

  • error : (String) string containing error message
  • errorData : (Object) object with non-fatal errors, keys – filenames, values – error message
  • select : (Array) array of hashes of files/directories which will be selected after action by client (upload, mkdir, mkfile и т.д.)
  • debug : (Object) object contains debug information

Commands of client not always match connector commands:

  • reload, back client commands use connector command open
  • list, icons, quicklook, copy, cut client commands work without request to connector

Any connector command which get invalid argument from client stops it execution and returns error message, except open command which returns error message and contents ot root directory.

Important! paths to files are not send in plain text, they are encoded using hash function from path (md5 or any other hash-function).

File manager initialization

Arguments sent by client to connector (client → server):

  • cmd : open
  • init : true
  • tree : true

Example: http://localhost:8001/~troex/cgi/connector.py?cmd=open&init=true&tree=true

Response (server → client): see open command description, additionally response contains:

  • disabled : (Array) list of disabled commands
  • params: (Object)
    • dotFiles : (Boolean) allow hidden files begining with dot
    • uplMaxSize : (String) max upload size (example: 128M)
    • archives : (Array) list of mime-type archives which can be created by connector
    • extract : (Array) list of mime-type archives which connector can extract
    • url : (String) URL where file root is located

Example of correct answer:

JSON:


{
    "cwd": {
        "name"  : "Home",
        "hash"  : "b4473c8c08d1d499ecd7112f3398f125",
        "rel"   : "Home",
        "date"  : "30 Jan 2010 14:25",
        "mime"  : "directory",
        "size"  : 0,
        "read"  : true,
        "write" : true,
        "rm"    : false
    },
    "cdc": [
    {
        "name"  : "test",
        "hash"  : "ac4b61565950a73395c871f9c3fc7362",
        "date"  : "Today 14:11",
        "mime"  : "directory",
        "size"  : 102,
        "read"  : true,
        "write" : true,
        "rm"    : true
    },
    {
        "name"  : "link to README", 
        "hash"  : "4fc059e61577f0267fbd6c1c5bafb1b4", 
        "url"   : "http://localhost:8001/~troex/git/elfinder/files/wiki/README.txt", 
        "date"  : "Today 16:50", 
        "mime"  : "text/plain", 
        "size"  : 10, 
        "read"  : true, 
        "write" : true, 
        "rm"    : true, 
        "link"  : "8d331825ebfbe1ddae14d314bf81a712", 
        "linkTo": "Home/README.txt", 
        "parent": "b4473c8c08d1d499ecd7112f3398f125"
    }, 
    {
        "name"  : "logo.png", 
        "hash"  : "a696323d7fd86513754004ba8bc12967", 
        "url"   : "http://localhost:8001/~troex/git/elfinder/files/wiki/logo.png", 
        "date"  : "11 Nov 2009 21:57", 
        "mime"  : "image/png", 
        "size"  : 18782, 
        "read"  : true, 
        "write" : true, 
        "rm"    : true,
        "resize": true,      
        "dim"   : "200x150",
        "tmb"   : "http://localhost:8001/~troex/git/elfinder/.tmb/a696323d7fd86513754004ba8bc12967.png"
    }, 
    {
        "name"  : "README.txt",
        "hash"  : "8d331825ebfbe1ddae14d314bf81a712",
        "url"   : "http://localhost:8001/~troex/git/elfinder/files/wiki/README.txt",
        "date"  : "Today 14:25",
        "mime"  : "text/plain",
        "size"  : 1171,
        "read"  : true,
        "write" : true,
        "rm"    : true
    }
    ],
    "tree": {
        "name"  : "Home",
        "hash"  : "b4473c8c08d1d499ecd7112f3398f125",
        "read"  : true,
        "write" : true,
        "dirs"  : [
        {
            "name"  : "test",
            "hash"  : "ac4b61565950a73395c871f9c3fc7362",
            "read"  : true,
            "write" : true,
            "dirs"  : [
            {
                "name"  : "test2",
                "hash"  : "b3615611cf9f8f6a8821ef20eda450b5",
                "read"  : true,
                "write" : true,
                "dirs"  : []
            }
            ]
        }
        ],
    },
    "disabled"  : [],
    "params"    : {
        "url"        : "http://localhost:8001/~troex/git/elfinder/files/wiki",
        "dotFiles"   : true,
        "uplMaxSize" : "15M",
        "extract"    : [
            "application/x-7z-compressed",
            "application/x-tar",
            "application/x-gzip",
            "application/x-bzip2",
            "application/zip"
        ],
        "archives"   : [
            "application/x-7z-compressed",
            "application/x-tar",
            "application/x-gzip",
            "application/x-bzip2",
            "application/zip"
        ]
    }
}

Command list

open – open directory or send file to browser
mkdir – create new directory
mkfile – create new text file
rename – rename directory or file
upload – upload files
ping – service command, needed for Safari (file upload)
paste – make a copy or move files/directories to selected destination
rm – delete files/directories
duplicate – duplicate file/directory
read – get text file content
edit – save text file content
extract – extract archive
archive – compress files/directories into archive
tmb – create thumbnails for images that don’t have them
resize – resize image

Command description

open

Open directory or send file to browser.

1. Directory open

Arguments:

  • cmd : open
  • target : hash of directory to open
  • tree : Optional argument, if set additionally include file tree in response

Response must contain (Object) cwd and (Array) cdc, additionally can contain (Object) tree and/or (Boolean) tmb, example:


{
    "cwd" : { // (Object) Current Working Directory - information about current directory
        "name"  : "Home",                             // (String)  directory name
        "hash"  : "b4473c8c08d1d499ecd7112f3398f125", // (String)  hash from absolute path to current dir
        "mime"  : "directory",                        // (String)  always set to "directory"
        "rel"   : "Home",                             // (String)  relative path to current directory
        "size"  : 0,                                  // (Number)  directory size in bytes
        "date"  : "30 Jan 2010 14:25",                // (String)  modification time (mtime)
        "read"  : true,                               // (Boolean) read access
        "write" : true,                               // (Boolean) write access
        "rm"    : false                               // (Boolean) delete access
    },
    "cdc" : [ // (Array) (of Objects) Current Directory Content - info about current dir content
    {
        "name"  : "link to README",                   // (String)  file/dir name
        "hash"  : "4fc059e61577f0267fbd6c1c5bafb1b4", // (String)  hash
        "url"   : "http://localhost:8001/~troex/git/elfinder/files/wiki/README.txt", // (String) URL
        "date"  : "Today 16:50",                      // (String)  modification time (mtime)
        "mime"  : "text/plain",                       // (String)  MIME-type of file or "directory"
        "size"  : 10,                                 // (Number)  file/dir size in bytes
        "read"  : true,                               // (Boolean) read access
        "write" : true,                               // (Boolean) write access
        "rm"    : true,                               // (Boolean) delete access
        "link"  : "8d331825ebfbe1ddae14d314bf81a712", // (String)  only for links, hash of file to
                                                      //           which point link
        "linkTo": "Home/README.txt",                  // (String)  only for links, relative path to
                                                      //           file on which points links
        "parent": "b4473c8c08d1d499ecd7112f3398f125", // (String)  only for links, hash of directory
                                                      //           in which is linked file is located
        "resize": true,                               // (Boolean) only for images, if true will
                                                      //           enable Resize contextual menu
        "dim"   : "600x400",                          // (String)  only for images, dimension of image
                                                      //           must be set if resize is set to true.
        "tmb"   : "http://localhost:8001/~troex/git/elfinder/files/.tmb/4fc059e61577f0267fbd6c1c5bafb1b4.png"
                                                      // (String) only for images
                                                      // URL to thumbnail
    },
    {
        // ...
    }
    ],
    "tree" : { // (Object) directory tree. Optional parameter, only if "tree" was requested
	"name"  : "Home",                             // (String)  dir name
        "hash"  : "b4473c8c08d1d499ecd7112f3398f125", // (String)  hash
        "read"  : true,                               // (Boolean) read access
        "write" : true,                               // (Boolean) write access
        "dirs"  : [                                   // (Array) (of Objects) array of child directories
        {
            "name"  : "test",
            "hash"  : "ac4b61565950a73395c871f9c3fc7362",
            "read"  : true,
            "write" : true,
            "dirs"  : [
            {
                // ...
            },
            {
                // ...
            }
            ]
        }
    },
    "tmb" : true // (Boolean) Optional parameter, if true, will cause client to initiate _tmb_ commands.

}

  • Important!* if invalid target argument was requested, connector will root directory content (cdc, cdw_) and error message (_error).

2. File open (send file contents to browser).

Аргументы:

  • cmd : open
  • target : hash of file
  • current : hash of current directory where file is located

Response:

File must be send to browser with valid headers.

mkdir

Create new directory.

Arguments:

  • cmd : mkdir
  • current : hash of current directory where new directory will be created
  • name : name of new directory

Response: open with directory tree and select – hash of new directory


{
    // open
    "cwd"   : {
        // ...
    },
    "cdc"   : [
        // ...
    ],
    "tree"  : {
        // ...
    },
    "select": [ "ac4b61565950a73395c871f9c3fc7362" ] // (String) hash of new directory
}

mkfile

Create new text file.

Arguments:

  • cmd : mkfile
  • current : hash of current directory where new file will be created
  • name : name of new file

Response: open and select – hash of new file

rename

Rename file/directory.

Arguments:

  • cmd : rename
  • current : hash of directory where file is located
  • target : hash of file/directory which to rename
  • name : new name

Response: open (if directory was renamed then return open with tree) and select – hash of renamed file/directory

upload

File upload.

Arguments (send using POST):

  • cmd : upload
  • current : hash of directory where to upload files
  • upload : array of files to upload (upload[])

Response:

1. If no files where uploaded return:


{
    "error" : "Unable to upload files"
}

2. If at least one file was uploaded response with open and select. If some files failed to upload append error and errorData:


{
    // open
    "select"    : [ "8d331825ebfbe1ddae14d314bf81a712" ], // (Array)  array of hashes of files that were uploaded
    "error"     : "Some files was not uploaded",          // (String) return if not all files where uploaded
    "errorData" : {                                       // (Object) warnings which files were not uploaded
        "some-file.exe" : "Not allowed file type"         // (String) "file name": "error"
    }
}

ping

Service command needed to workaround Safari bug while uploading http://www.webmasterworld.com/macintosh_webmaster/3300569.htm

Arguments:

  • cmd : ping

Response: send empty page with headers Connection: close

paste

Copy or move file/directory.

Arguments:

  • cmd : paste
  • src : hash of source directory where files/directories which to copy is located
  • dst : hash of destination directory where to copy
  • targets : array of hashes copied files/directories
  • cut : 1 if you move or not set if copy

Response:
If copy/move was successful response open with file tree. If some files/directories were not copied or moved than add error and errorData to response.

Important! Command must stop execution if any error occurred. It is not allowed to rewrite files/directories with the same names.

rm

Delete file or directory (recursive).

Arguments:

  • cmd : rm
  • current : hash of directory from where to delete
  • targets : array of hashes of files/directories to delete

Response: open with directory tree, on errors add error and errorData.

duplicate

Create copy of file/directory. Name of the copy must be unique and formed next way (basename + " copy _NUM_" + ext):

  • readme.txt
  • readme copy.txt
  • readme copy 1.txt
  • readme copy 2.txt

Arguments:

  • cmd : duplicate
  • current : hash of directory where to make a copy
  • target : hash of file/directory which to copy

Response: open (if directory was duplicated response open with tree), select – hash of duplicated object.

read

Read text file and response with its contents.

Arguments:

  • cmd : read
  • current : hash of directory in which file is located
  • target : hash of the file

Response: content – content of the file


{
    "content": "Hello world!" // (String) file content 
}

edit

Save submitted text to file.

Arguments (send using POST):

  • cmd : edit
  • current : hash of directory where to save file
  • target : hash of file in which content will be saved
  • content : new content of the file

Response: file – object the same as cdc object in open command


{
    "file" : {
        "name"  : "README.txt",
        "hash"  : "8d331825ebfbe1ddae14d314bf81a712",
        "url"   : "http://localhost:8001/~troex/git/elfinder/files/wiki/README.txt",
        "date"  : "Today 14:25",
        "mime"  : "text/plain",
        "size"  : 1171,
        "read"  : true,
        "write" : true,
        "rm"    : true
    }
}

extract

Extract archive.

Arguments:

  • cmd : extract
  • current : hash of directory where archive is located
  • target : hash of archive

Response: open with directory tree

archive

Create archive from files/directories.

Arguments:

  • cmd : archive
  • type : mime-type of archive to create
  • current : hash of directory where files/directories that we add to archive is located
  • targets : array of hashes of files/directories to add to archive

Response: open, select – hash of new archive

tmb

Background command. Creates thumbnails for images that don’t have them yet. Amount of thumbnails to create per request is configured in connector with option tmbAtOnce. By default – 5.

Arguments:

  • cmd : tmb
  • current : hash of directory where images don’t have thumbnails yet

Response:


{
    "current": "b4473c8c08d1d499ecd7112f3398f125", // (String) hash of directory for which thumbnails were created
    "images" : {                                   // (Object)
        "a696323d7fd86513754004ba8bc12967":        // (String) hash of image path
            "http://localhost:8001/~troex/git/elfinder/files/.tmb/a696323d7fd86513754004ba8bc12967.png"
                                                   // (String) thumbnail URL
    }, 
    "tmb": true  // (Boolean) true if more thumbnails can be created in current directory
                 //           or not set if all images have thumbnails
}

resize

Resize image.

Arguments:

  • cmd : resize
  • current : hash of directory where image is located
  • target : hash of image path
  • width : new width for image
  • height : new height for image

Response: open, select – hash of image path.

In order for the contextual menu Resize to appear for a given file, its cdc entry must contain both resize and dim. resize must be set to true and dim must be a string containing the file’s width and height (eg. “600×400”). If resize is specified without dim the contextual menu will appear, but will not function correctly.

Clone this wiki locally