This article describes how to get CKFinder up and running by adjusting some basic settings.
The CheckAuthentication() Function
By default, CKFinder will not work due to authentication restrictions. You must first make sure that you have configured it correctly, and then enable it.
Once you have completely configured CKFinder, you are ready to enable it for use. The CheckAuthentication()
function is used for that. In this function you must implement the code ensuring that the requests are coming from an authenticated user. This is usually done by assigning a session variable when the user logs into your system.
If the user is properly authenticated, the fuction should return true
. We strongly recommend you to NOT simply return true
from this function without implementing authentication checks. Without authentication support anonymous users would be able to use CKFinder on your website, including uploading and deleting files from your server.
The following is a sample implementation of the CheckAuthentication()
function:
function CheckAuthentication() { return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized']; }
License
If you purchased CKFinder, you should put your license key in the config.php
file:
$config['LicenseName'] = 'put your license name here'; $config['LicenseKey'] = 'put your license key here';
If you leave these fields blank, CKFinder will be fully functional, but it will be running in demonstration mode.
$baseUrl
The $baseUrl
is the base path used to build the final URL for the resources handled by CKFinder.
Examples:
$baseUrl = 'http://example.com/ckfinder/files/'; $baseUrl = '/userfiles/';
If you leave this field empty, the default value (/userfiles/
) will be used.
$baseDir
The $baseDir
is the path to the local directory (on the server) which points to the $baseUrl
URL described above. This is the path used by CKFinder to handle the files on the server. Full write permissions must be granted to this directory.
You may point it to a directory directly:
$baseDir = '/home/login/public_html/ckfinder/files/'; $baseDir = 'C:/SiteDir/CKFinder/userfiles/';
Or you may let CKFinder discover the path based on $baseUrl
:
$baseDir = resolveUrl($baseUrl);
Bear in mind that CKFinder will only discover the path, when the base URL is a local Web path (relative to document root). Example:
$baseUrl = '/userfiles/'
If it is a full URL address, like the following one:
$baseUrl = 'http://example.com/ckfinder/files/'
the path will not be discovered.