ckeditor集成ckfinder后,上传文件全部自动保存到images文件夹中,多了后管理不方便,可以把文件图片按照年和月生成子文件夹,然后把图片存入子文件夹中。
在/ckfinder/core/connector/php/php*/CommandHandler/FileUpload.php中的
$sServerDir = $this->_currentFolder->getServerPath();
$iCounter = 0;
后面加上下面代码
$now=time();
$yearDir=$sServerDir.’/’.date(’Y',$now).’/';
if (!file_exists($yearDir)&&!is_dir($yearDir)){
mkdir($yearDir,0777);
}
$monthDir=$yearDir.date(’m',$now);
if (!file_exists($monthDir)&&!is_dir($monthDir)){
mkdir($monthDir,0777);
}
$sServerDir=$monthDir;
$oRegistry->set(”FileUpload_url”, $this->_currentFolder->getUrl().date(’Y',$now).’/’.date(’m',$now).’/');//这一个要传递给ErrorHandler的FileUpload.php文件,用以显示上传后的地址
//另外,如何修改图片上传框中的tab顺序(默认上传)
在ckeditor\plugins\image\dialogs\image.js中修改
contents:[{id;'upload''}],把id为upload的那段代码移到最前面即可
One Response to “ckeditor/ckfinder上传文件按日期生成文件夹”
老大夫 把我的博客地址换一下 谢谢
http://www.ozzy.net.ru
By ozzy on Jun 17, 2010