I am using CKEditor with KCFinder - i'd like to have personal upload files based on a dynamic value.
I'd like to dynamically change the folder that users can upload based on a SESSION value once they are logged in.
Once logged in i'd like to restrict the folder that a user can access via the KCFinder plugin So eg..
User abc their path would be abc/images
User foo their path would be foo/images
User abc cannot see foo's images & vice-versa
It can be done in many ways. I am explaining a process, which I applied as per my php applications' code structure. The same code structure/framework I followed for different applications, with each application as a sub-folder in my server. So, there is a logical need to use one single CKeditor with KCfinder and configure it in some way, so that it work properly for all the applications. The content part of CKeditor is ok. It can easily be reused by different applications or projects from a single CKeditor component. But the problem arises with file upload, like image, video or any other document. To make it applicable for different project, the files must be uploaded in separe folders for different projects. And for that $_CONFIG['uploadURL'] must by configured with dynamic folder path, means different folder path for each project, but calling the the same CKeditor KCfinder component in the same location. I am explaning some differnt process together in a step-by-step way. Those worked for me fine with KCfinder version 2.51 and I hope they will work for others as well. If it does not work for other developrs, then may be they need to make some tweaks in those process as per their project code structure and folder write permission as well as per the CKeditor and KCfinder version.
1) In CKeditor\filemanagers\kcfinder_2_51\config.php file
a) In $_CONFIG array definition, search for this line 'disabled' => false, and if you find any replace it with 'disabled' => true, At the end of that file put the following code. The code is self explaining with the logic and details commented out within it. The code is:
2) In ckeditor\filemanagers\kcfinder_2_51\js\browser\misc.js
Search for this line: var data = 'browse.php?type=' + encodeURIComponent(this.type) + '&lng=' + this.lang;
Replace it with that line:
3) In ckeditor\filemanagers\kcfinder_2_51\tpl\tpl_javascript.php
Search for this line: browser.type = "type) ?>";
Put these commands after that line:
4) In ckeditor\filemanagers\kcfinder_2_51\core\uploader.php Search for this lines in __construct() function :
And comment out that full section
4) Now where you want to show the CKeditor in your project, you have to put those lines in the corresponding php file/page, obviously with changed values of variables corresponding to your project/app. But please read the comments first to decide what lines you should keep and what should be commented out as per your flow:
And you are done.
I had the same issue and to make things worse it depends on who logged in, administrator or a standard member.
Granted I integrated it into TinyMCE but I think the principles are the same
Here is my solution to the problem
My folder structure is
Initialise the php session at the top of the config.php file
session_start()
Edit the 'types' => array and comment out all the different 'types'
Add the following 'type' to the array
$_SESSION['fold_type'] => "*img swf flv avi mpg mpeg qt mov wmv asf rm",
Save your config.php file
Open your application page where you initialise your editor and call KCFinder
Before initialising your editor, add the following lines declaring the various KCFinder variables
or
7 Leave the line where you call the uploader like this;
Set upload folder dynamically for KCFinder