我从山中来

我是网络一看客
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

CKFinder里动态设置文件上传路径的方法

Posted on 2010-12-08 19:41  我从山中来  阅读(2203)  评论(0编辑  收藏  举报

在CKFinder里,文件上传路径主要配置ckfinder/config.php中的$baseUrl变量

 

/*
$baseUrl : the base path used to build the final URL for the resources handled
in CKFinder. If empty, the default value (/userfiles/) is used.

 


Examples:
    $baseUrl = 'http://example.com/ckfinder/files/';
    $baseUrl = '/userfiles/';


ATTENTION: The trailing slash is required.
*/


$baseUrl = '/ckfinder/userfiles/';

上边这是它的默认配置,该文件里已说明,要么它是以http开头的url地址,要么就是以"/"开头的地址,"/"代表的是DocumentRoot的位置,如果以"/"开头写死了,当程序迁移的时候又得改这路径,怎么办?


今天摸索了一下午,终于找到一个办法,如果我的项目是MyApp,我的ckfinder就放在MyApp下边,我想把文件上传到MyApp/uploads/userfiles/下,这时我就可以这样做:

$phpSelf = $_SERVER["PHP_SELF"];
$baseUrl = substr($phpSelf, 0, strpos($phpSelf, 'ckfinder')).'uploads/userfiles/';
这样即使我的MyApp变动了位置,也不用更改$baseUrl的值了。

 

哈哈,真是高兴~