Recently in a project I need to use some Rich Text Formatter (RTF)/WYSIWYG text editor, I decided to select some of available in web.
I wanted to upload images via WYSIWYG text editor, so I used:
A) - CKEditor
B) - KCFinder as alternative of CkFinder
C) - Prevent WYSIWYG upload access, if user not login
I wanted absolute url of upload image or selected image from WYSIWYG text editor e.g. "http://localhost/CkEditor-KcFinder/upload/4856dkfgd674768.jpg"
I also found that many users are confuse to setup KCFinder with CKEditor. They all are searching "How to get absolute url in KCFinder?".
So I just made a demo about KCFinder setup with CKEditor. The code ready to use, what you have to do
- download repository/clone
- unzip the source code in your wamp/lamp/xamp root folder and access the url to start demo
- open http://localhost/CkEditor-KcFinder/
A) - CkEditor 4.6.2
B) - KcFinder 3.12
A) - Project Path - D:/wamp/www/CkEditor-KcFinder
B) - Upload Path - D:/wamp/www/CkEditor-KcFinder/upload
C) - CkEditor Path - D:/wamp/www/CkEditor-KcFinder/ckeditor
D) - KcFinder Path - D:/wamp/www/CkEditor-KcFinder/kcfinder
Make the changes according to your requirement in "D:/wamp/www/CkEditor-KcFinder/settings.php"
- KcFinder Core Changes
File: D:\wamp\www\CkEditor-KcFinder\kcfinder\core\bootstrap.php
# To check valid SESSION, I have added below code:
/**
* Start the PHP SESSION if not started already
*/
if (!session_id()) session_start();
/**
* First of all Check Valid SESSION to access rest
*/
if (!isset($_SESSION[$_SESSION['AuthCheckKey']]) || $_SESSION[$_SESSION['AuthCheckKey']] === false) {
die ('Unauthorized access detected.. Service terminated.');
}
- KcFinder Config Changes
File: D:\wamp\www\CkEditor-KcFinder\kcfinder\conf\config.php
We don't need to set anything in 'config.php' actually, if we are using, 'KCFINDER' session variable to store the session configuration.
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 conf/config.php file. For example, to enable KCFinder you should execute from your application:
Please see the details: https://kcfinder.sunhater.com/install
$_SESSION['KCFINDER'] = array(
'disabled' => false
);
'disabled' => '',
'uploadURL' => '',
'uploadDir' => '',
/**
* KcFinder has a SESSION key name 'KCFINDER'
* You can use this as setup your dynamic config vales
* if you set uploadURL and uploadDir via SESSION, KcFinder ignore config.php
* to get these values and it start using SESSION values
*/
$_SESSION['KCFINDER'] = array(
'disabled' => false,
'uploadURL' => 'http://www.site.com/upload',
'uploadDir' => 'var/htdocs/www/upload'
);
Thanks to kcfinder and ckeditor to make these AWESOME tools.. :)