fckeditor php上传文件重命名的设置

所属分类: 网络编程 / 网页编辑器 阅读数: 1550
收藏 0 赞 0 分享
这里经过摸索:找到了一个重命名的方法,大家看看好不好使。
首先:我希望上传的文件根据日期来组织文件夹
请修改editor\editor\filemanager\connectors\php文件夹下的:config.php文件
找到如下的内容:
// Path to user files relative to the document root.
$Config['UserFilesPath'] =
修改为:
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/uploadfiles/'.date("Ym")."/" ;
这样上传的文件就按照日期存放了。
其次:重命名
请修改该文件夹下的io.php文件
找到:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
global $Config ;
$sNewFileName = stripslashes( $sNewFileName ) ;
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
 $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
// Remove \ / | : ? * " < >
$sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFileName );
return $sNewFileName ;
}
修改为:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
global $Config ;
$sNewFileName = stripslashes( $sNewFileName ) ;
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
 $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
$sExtension = substr( $sNewFileName, ( strrpos($sNewFileName, '.') + 1 ) ) ;
$sNewFileName = my_setfilename().'.'.$sExtension;
return $sNewFileName ;
}
function my_setfilename(){
$gettime = explode(' ',microtime());
$string = 'abcdefghijklmnopgrstuvwxyz0123456789';
$rand = '';
for ($x=0;$x<12;$x++)
 $rand .= substr($string,mt_rand(0,strlen($string)-1),1);
return date("ymdHis").substr($gettime[0],2,6).$rand;
}
这样上传的文件就可以实现重命名了。
更多精彩内容其他人还在看

在asp.net中KindEditor编辑器的使用方法小结

由于国外的服务器好象对一些要引用dll编辑器由于安全问题,锁定了web.config中的一些权限,在先试了FreeTexbox不行,FCKEditor也不行,因为都是要引用dll文件,最后同事介绍一款 纯js的kindeditor编辑器,
收藏 0 赞 0 分享

FCK判断内容是否为空(如果只是去空格,那么这种方式是错误的)

一般来说,像input里面的值都可以通过将内容去空格判断是否为空,但是FCK没那么简单,因为当你多打几个空格或者多打一些回车,它会自动地生成一些<p>标签,如果再用原先去空格判断的方法,显然是不可取的。
收藏 0 赞 0 分享

当使用ckeditor控件时,需要校验输入内容是否为空的一种解决办法(转帖)

这样是我们写程序中最经常的写法 提交之前进行验证内容是否为空!
收藏 0 赞 0 分享

FCKeditorAPI 手册 js操作获取等

FCKeditorAPI 手册 js操作控制,获取等函数代码,使用网页编辑器的朋友可以参考下。
收藏 0 赞 0 分享

autogrow 让FCKeditor高度随内容增加的插件

让FCKeditor高度随内容增加的插件,这个插件在默认情况下可能运行不正常,必须做一点修改才可以。
收藏 0 赞 0 分享

自己打造HTML在线编辑器的实现难点分析

到目前为止,我已经开发了两个HTML编辑器了,一个用在公司的CMS项目,另一个用在这个Blog(TidyEditor,暂时没有单独发布)。下面总结一下开发的难点以及应对方法。
收藏 0 赞 0 分享

常用网页编辑器漏洞手册(全面版)fckeditor,ewebeditor

常用网页编辑器漏洞手册(全面版)fckeditor,ewebeditor,使用这类编辑器的朋友一定要注意下。
收藏 0 赞 0 分享

myFocus 一个KindEditor的焦点图插件

使用KindEditor(富文本编辑器)提供的接口将myFocus(焦点图库)集成在KindEditor上
收藏 0 赞 0 分享

通过Fckeditor把图片上传到独立图片服务器的方法

大部分网站的后台,都是把图片上传到本地服务器上,但图片也消耗很多带宽,门户网站都有单独的图片服务器,怎么实现呢?
收藏 0 赞 0 分享

eWebEditor 辑器按钮失效 IE8下eWebEditor编辑器无法使用的解决方法

最近我把IE浏览器更新到了IE8.0,在用eWebEditor在线HTML文本编辑器的时候点击eWebEditor上的所有编辑按钮都没用,只看到浏览器状态栏左下角显示网页上有错误,于是上网查了一下。终于找到解决的方法,测试后正常。
收藏 0 赞 0 分享
查看更多