分类分类
更新时间:2026-03-28 23:51:12作者:zhao
ecshop是一套非常好的网店系统,fckeditor也是个不错的html编辑器,常用于各种cms及商城系统实现在纺编辑html代码,然后ecshop使用的fckeditor在上传图片和其它文件时是没有按目录存放的。
我们很多人都习惯上传的文件按年和月这样的日期存放这样不至于上传文件夹存放的内容太多太杂,影响系统的稳定性,同时上传的文件也没有进行重命名,当我们上传中文文件名的文件时有些时候会出错,下面我们就来实现:
一、ecshop的fckeditor上传文件时按年和日存放,假如我们是2012年3月存放的,系统会自动建一个文件夹201207,方法
打开includes/fckeditor/editor/filemanager/connectors/php/config.php,找到:
修改前的代码:
// Path to user files relative to the document root.
$Config['UserFilesPath'] = $root_path . IMAGE_DIR . '/upload/';
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:MySiteuserfiles' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = ROOT_PATH . IMAGE_DIR . '/upload/' ;
修改后的代码:
// Path to user files relative to the document root.
$Config['UserFilesPath'] = $root_path . IMAGE_DIR . '/upload/'.date('Ym').'/';
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:MySiteuserfiles' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = ROOT_PATH . IMAGE_DIR . '/upload/'.date('Ym').'/';
然后保存,非常简单,仅是在这两行后面增加了 .date('Ym').'/'
二、ecshop的fckeditor上传文件时自动重命名,方法:
找到文件:includes/fckeditor/editor/filemanager/connectors/php/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( '/\|/|||:|?|*|"|<|>|[[:cntrl:]]/', '_', $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 ) ;
// Remove / | : ? * " < >
//$sNewFileName = preg_replace( '/\|/|||:|?|*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ;
$sExtension = substr( $sNewFileName, (strrpos($sNewFileName,'.') + 1 ) ) ;
$sNewFileName = date('YmdHis').rand(0,999).'.'.$sExtension;
return $sNewFileName ;
}
就是把$sNewFileName = preg_replace( '/|/|||:|?|*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ;注释掉,新增加:
$sExtension = substr( $sNewFileName, (strrpos($sNewFileName,'.') + 1 ) ) ;
$sNewFileName = date('YmdHis').rand(0,999).'.'.$sExtension;
保存后,在ecshop的后台测试就会发现我们上传的图片按年月分目录保存并自动重命名了!
经测试ecshop V2.7.3 20120411版本还未失效的!
相关
王道三国策略游戏380.18 MBv0.0.12026-03-28
下载刮个爽手机版休闲益智186.96 MBv1.0.282026-03-28
下载龙符天祭策略游戏756.03 Mv22026-03-28
下载入魂一番赏app网上购物106.66 Mv4.3.52026-03-28
下载童话师经营养成504.02 Mv1.1.52026-03-28
下载Bebo Cam app图像拍照264.51 Mv2.3.02026-03-28
下载纯三国官方正版策略游戏167.24 Mv0.0.12026-03-28
下载Poka Cam app图像拍照74.7 Mv1.8.02026-03-28
下载COLMO app趣味娱乐199.15 Mv2.3.5.22026-03-28
下载愤怒的小鸟变形金刚苹果版休闲游戏439.4 Mv2.39.02026-03-28
下载这也能切苹果版休闲游戏479.6 Mv21342026-03-28
下载口袋吉伊卡哇苹果手机版模拟游戏920.4 Mv2.0.02026-03-28
下载










