简体   繁体   中英

CKFinder / CKEditor

I am using CKFinder to upload files to my site where all my users should have their own folder storing their own files in them.

My desired result is that the folder for user files uploaded will be ckfinder/userfiles/$USERNAME

I have the following information in the config.php file of CKFinder that simply is not working for me.

Help very much appreciated and needed.

$docRoot = getenv("DOCUMENT_ROOT"); 
$siteName = $_SERVER['HTTP_HOST'];
$USERNAME = $_SESSION['thisusername']; // session via main page username value
$baseUrl = 'http://' . $siteName . '/ckfinder/userfiles/';
$baseDir =  $docRoot . '/ckfinder/userfiles/';

/*=================================== Backends    =====*/
$config['backends'][] = array(
'name'         => 'default',
'adapter'      => 'local',
'baseUrl'      => "/ckfinder/userfiles/",
'root'         => $baseDir,
'chmodFiles'   => 0777,
'chmodFolders' => 0755,
'filesystemEncoding' => 'UTF-8',
);

you have to use the variable $USERNAME somewhere, else nothing will happen by itself. Most likely: 'baseUrl' => "/ckfinder/userfiles/" . $USERNAME ."/", 'baseUrl' => "/ckfinder/userfiles/" . $USERNAME ."/",

I resolved this by putting into the config.php the following:

$USERNAME = $_SESSION['thisusername'];
if ($USERNAME){
    $baseUrl = 'http://www.myurl.org/ckfinder/userfiles/' . $USERNAME . '/';
    $baseDir =  $docRoot . '/ckfinder/userfiles/' . $USERNAME . '/';
}else{
    $baseUrl = 'http://www.myurl.org/images/';
    $baseDir =  $docRoot . '/images/';  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM