Welcome Guest, Not a member yet? Register   Sign In
Integrating CKfinder with a dynamical BaseUrl for file browsing and uloading ?
#1

[eluser]moonbeetle[/eluser]
With the help of the CKeditor Helper, integrating CKeditor was a breeze. A big thumbs up for the developer who created and shared this.
Now I need to integrate CKfinder. Basic integration is not that hard but the one thing I couldn't solve at this point is how to set the $BaseUrl variable dynamically. Since I have to deal with multiple upload directories I need to set the $BaseUrl dynamically and pass the value to CKfinder's config.php.

Using a PHP $_SESSION['BaseUrl'] seems obvious but since I'm already using CI's session library (or will be switching to Session Hybrid after what I read this morning) I'm not sure I can use $_SESSION at all? Can I ?

I might outsource this job so if you're interested, send me a PM.
#2

[eluser]businessman332211[/eluser]
Yep, just had the same problem as you. So let me help. In the config.php file for CKFinder.
Code:
$session = unserialize($_COOKIE['ci_session']);

$funeralhome_id = $session['funeralhome_id'];
$baseUrl = '/ckfinder_userfiles/' . $funeralhome_id . '/';

That's it. You unserialize the session and then you can use the session just as an array. So if you had
the variable "user_id" in there..then just do what I showed you above but replace every instance of "funeralhome_id" with "user_id".

Also create the "ckfinder_userfiles" folder in the main directory and upload it. It'll handle all of the rest automatically.

I hope that helped.
#3

[eluser]Binod Kumar Luitel[/eluser]
Nice instruction mate, you've saved my day thanx
#4

[eluser]valajbeg[/eluser]
There is much easier way to do that.

Open config.php in CKFinder and there is $config array variable $config['ResourceType'][]

Adjust settings as you need and when you load.

Example config, you can add as much different configs as you wish
Code:
$config['ResourceType'][] = Array(
        'name' => 'DEFINE-YOUR-NAME',
        'url' => $baseUrl . 'images',
        'directory' => $baseDir . 'images',
        'maxSize' => "20M",
        'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
        'deniedExtensions' => '');

and when you call popup with button call it OnClick =

Code:
BrowseServer( 'DEFINE-YOUR-NAME:/', 'field_name' );


If you want to automatically select specific folder inside just add path after DEFINE-YOUR-NAME:/FURTHER-PATH

and that is it Smile


p.s. you have to define $baseUrl behind as "deep as possible
that is obvious but just in case Wink




Theme © iAndrew 2016 - Forum software by © MyBB