ckeditor集成ckfinder后,上传文件全部自动保存到images文件夹中,多了后管理不方便,可以把文件图片按照年和月生成子文件夹,然后把图片存入子文件夹中。
在/ckfinder/core/connector/php/php*/CommandHandler/FileUpload.php中的
修改:
$sExtension=CKFinder_Connector_Utils_FileSystem::getExtension($sFileName);
//$sFileName=date("YmdHis").".".$sExtension;
$sFileName=mktime().".".$sExtension;
$oRegistry->set("FileUpload_fileName", $sFileName);//文件以时间戳命名。
另外
$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文件,用以显示上传后的地址
//
另外需要更改
ckfinder 下的config.php 里生成缩略图的'directory' => $baseDir . 'thumbs',
//另外,如何修改图片上传框中的tab顺序(默认上传)
在ckeditor\plugins\image\dialogs\image.js中修改
contents:[{id;'upload''}],把id为upload的那段代码移到最前面即可
One Response to “ckeditor/ckfinder上传文件按日期生成文件夹”