Documentation


Donate

Installation

  1. Copy the distribution files to your web server inside the /kcfinder directory or any other directory in your web site.
  2. Create a directory in the server to hold all uploaded files. By default, KCFinder is configured to use the /kcfinder/upload/ directory.
  3. Make the above upload directory writable by the web server. On Linux, chmod it to 0777.

Configuration

KCFinder settings are located in config.php file organized as associative array. The keys of the array are the names of the settings. The settings which names don’t begin with underscore can be overridden with an user session. I'll call them Dynamic Settings. The dynamic settings must not be removed or commented from the config.php file. If you are upgrading KCFinder please check the new config.php file for new dynamic settings which should be added to your old configuration file. The other type of settings, which names begin with underscore, can be removed or commented from the config.php file and cannot be overridden by an user session, I'll call them Static Settings.

Dynamic Settings

'disabled' => true,

By default KCFinder is disabled. If you just set this setting to false all public visitors can upload and manage files on your web site. It is recommended to override this setting with sesssion configuration so only registered users can use KCFinder.

'denyZipDownload' => false,

KCFinder allows downloading folders or the files in your clipboard as a ZIP file. To use this functionality PHP ZIP extension should be available on your server. If you store big files, as movies or ISO images, creating such huge archive can cause problems with your server. To disable downloading multiple files as a single ZIP archive, you should set this setting to true.

'denyUpdateCheck' => false,

If you set this to true, online checking for new version in "About" box will not appear. Available since version 2.4.

'denyExtensionRename' => false,

This setting is used to forbid the changing of file's extensions. If this option is set to true and an user tries to rename the file extensions, a warning message will appear and the operation will be canceled. Available since version 2.41.

'theme' => "oxygen",

The visual theme of KCFinder. Pick one from the themes directory.

'uploadURL' => "upload",

URL path to main directory for file uploads. In the example above the path is relative to KCFinder main directory. Other examples:
/files/upload - relative to the site root
../upload - 'upload' directory located in KCFinder parent directory
httр://yourdomain.com/upload - absolute URL path. Works in version 2.3 and above

'uploadDir' => "",

This setting is used when KCFinder can't automatically detect its local file system path to the folder specified in uploadURL setting. Change this setting only if KCFinder can't fetch the local file system path automatically.

'dirPerms' => 0755,
'filePerms' => 0644,

Default filesystem permissions for new files and directories created with KCFinder. Windows servers will skip these settings.

'access' => array(
 
    'files' => array(
        'upload' => true,
        'delete' => true,
        'copy' => true,
        'move' => true,
        'rename' => true
    ),
 
    'dirs' => array(
        'create' => true,
        'delete' => true,
        'rename' => true
    )
),

Defines user's write permissions for files and directories. Available since version 2.3.

'deniedExts' => "exe com msi bat php phps phtml php3 php4 cgi pl",

Global denied file extensions list. Will be checked when the user uploads or renames a file.

'types' => array(
   // The folowing directory types are just for an example
   'files'     => "",
   'flash'     => "swf",
   'media'     => "swf flv avi mpg mpeg qt mov wmv asf rm",
   'misc'      => "! pdf doc docx xls xlsx",
   'images'    => "*img",
   'mimages'   => "*mime image/gif image/png image/jpeg",
   'notimages' => "*mime ! image/gif image/png image/jpeg"
),

The Directory Types represented as associative array. The keys of the array defines directory names of the types. These directories will be created in the main upload directory. The values of the array defines the type of the files which can be uploaded in each directory. If the value is an empty string (Example: files), files of any type can be uploaded. There are three different value formats you can use:

  1. Space separated list of allowed extensions. (Example: media)
  2. Denied files extension list - space separated list that begins with "!" character. (Example: misc)
  3. Special types - types that begin with "*" character.
    • *img - Images which can be handled by GD extension. (Example: images)
    • *mime - List of MIME types of allowed files. Works only if Fileinfo PHP extension is available. (Example: mimages)
    • *mime ! - List of MIME types of denied files. (Example: notimages)
    Read this to learn how to make custom special types.

Since version 2.0, KCFinder supports specific settings for each Directory Type. You can define some of the dynamic settings to a Directory Type. To do this you should modify the schema of the types array by changing the values from string to associative array. The element with key type defines the types of files which can be uploaded, any other key defines specific Directory Type setting. Example:

'types' => array(
 
    'files' => array(
        'type' => "",
        'thumbWidth' => 100,
        'thumbHeight' => 100
    },
 
    'flash' => array(
        'type' => "swf",
        'denyZipDownload' => false
    },
 
    'images' => array(
        'type' => "*img",
        'thumbWidth' => 150,
        'thumbHeight' => 150
    )
 
),

The settings you can use for Directory Types are: disabled, theme, dirPerms, filePerms, denyZipDownload, denyExtensionRename, access, deniedExts, filenameChangeChars, dirnameChangeChars, maxImageWidth, maxImageHeight, thumbWidth, thumbHeight and jpegQuality.

'filenameChangeChars' => array(
    " " => "_",
    ":" => "."
),

This setting defines characters or strings that will be automatically replaced in file names during file upload or rename. This is useful for SEO purposes. In the example above all spaces in filenames will be changed to underscores and all ":" to "."

'dirnameChangeChars' => array(
    " " => "_",
    ":" => "."
),

Same as filenameChangeChars setting but related to directories creation and renaming.
These two settings are available since version 2.32 and by default they are empty arrays with commented elements inside. If you want to use them, you should remove the comments.

'mime_magic' => "",

Full path to magic file. This setting is related to *mime Special Directory Type. If you don't wish to use MIME type detection, you could skip this setting. The magic file must be on local filesystem. If you leave this setting empty the default magic file will be loaded. Default magic file path depends on your server's platform and on some platforms it is not defined (usually /usr/share/misc/magic).

'maxImageWidth' => 0,
'maxImageHeight' => 0,

Maximum image width and height. If uploaded image resolution exceeds these settings it will be automatically resized. If both are set to zero, images will not be resized. If one of these settings is set to zero, the image will be proportionally resized to fit the other setting.

'thumbWidth' => 100,
'thumbHeight' => 100,

Resolution for the generated thumbnail images.

'thumbsDir' => ".thumbs",

Thumbnails directory location, relative to main upload directory. If it does not exists KCFinder will automatically create it.

'jpegQuality' => 90,

JPEG compression quality of thumbnails and resized images.

'cookieDomain' => "",
'cookiePath' => "",

Domain and path, cookies will be sent to. If the cookieDomain is empty the domain from the browser URL will be used. If the cookiePath is empty, root ("/") path will be used. See _sessionDomain and _sessionPath settings for example.

'cookiePrefix' => 'KCFINDER_',

Cookie names prefix to prevent collisions with other integrated applications.

Static Settings

'_check4htaccess' => true,

Whether to check for .htaccess file in the main upload folder. If it is set to true and the file does not exist, KCFinder will create it. This is useful to prevent execution of PHP files from upload.

'_tinyMCEPath' => "/tiny_mce",

Path to TinyMCE sources. For more information check TinyMCE Integration.

'_sessionVar' => &$_SESSION['KCFINDER'],

In the example above session settings are linked to session variable KCFINDER (don't remove the "&" character). This session variable can be set by integrating application to configure KCFinder before its opening. It should contain an array with dynamic settings. The settings which don't exists in the array will use their values set in config.php file. For example, to enable KCFinder you should set the session below in your application code:

$_SESSION['KCFINDER'] = array();
$_SESSION['KCFINDER']['disabled'] = false;

Read Integration » Session Configuration for more information.

'_sessionLifetime' => 30,

Defines inactive user session lifetime in minutes. This setting needs _sessionDir to be set, otherwise other web scripts on your site can remove user sessions earlier. If you leave this setting commented, default session.gc_maxlifetime ini seting will be use.

'_sessionDir' => "/full/path/to/directory"

Full path to directory where user sessions are saved. Make sure that the web server has read and write permissions for this directory. If you leave this setting commented default session.save_path ini setting will be used.

'_sessionDomain' => ".mysite.com",
'_sessionPath' => "/my/path",

The session will be valid for the domain and path set in these settings. In the example above, the session will be valid for *.mysite.com/my/path. If you leave this settings commented the default session.cookie_domain and session.cookie_path ini settings will be used.

Minimizing JavaScript

You can minimize JavaScript code using many JavaScript compressors. The most popular is YUI Compressor which is a Java program. You need Java SDK to use it from the command line. You can also use online compressors instead. The following form will compress JavaScript code from entered URL. Please complete the URL with your domain at the beginning.

JavaScript URL:

Copy the copressed output and save it to your web server for example in js/browser.js. Then you need to modify tpl/tpl_javascript.php. Replace the following row:

<script src="js/browser/joiner.php" type="text/javascript"></script>

with:

<script src="js/browser.js" type="text/javascript"></script>

After that you can safely remove the whole js/browser directory - if you are not planning to make any changes in the future.