欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

fckeditor上傳文件按日期存放及重命名方法

 更新時(shí)間:2015年05月22日 09:28:47   投稿:junjie  
這篇文章主要介紹了fckeditor上傳文件按日期存放及重命名方法,本文修改了相關(guān)PHP文件實(shí)現(xiàn)這二個(gè)需求,需要的朋友可以參考下

1. 實(shí)現(xiàn) fckeditor 按日期分目錄的形式存放上傳的文件,比如今天是 2015年5月5日,那么今天上傳的文件都放在這個(gè)目錄里面去,明天上傳的則自動(dòng)創(chuàng)建并放在類似 2015-05-06 這樣的目錄里面去。

(1)找到 editor\editor\filemanager\connectors\php\ 文件夾下的 config.php 文件

(2)找到如下配置變量

查看代碼打印

復(fù)制代碼 代碼如下:

$Config['UserFilesPath'] = '/uploadfiles/';

將其值修改為:

查看代碼打印

復(fù)制代碼 代碼如下:

$Config['UserFilesPath'] = '/uploadfiles/'.date('Y-m-d').'/';

這樣上傳的文件就按照日期存放了。

2. 重命名 fckeditor 上傳的文件的方法

(1)找到 editor\editor\filemanager\connectors\php\io.php 文件:

(2)找到如下內(nèi)容:

復(fù)制代碼 代碼如下:

......
function SanitizeFileName( $sNewFileName ){
 global $Config ;
 $sNewFileName = stripslashes( $sNewFileName ) ;
 if ( $Config['ForceSingleExtension'] )
  $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
 $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFileName );
 return $sNewFileName ;
}
......

修改為:

復(fù)制代碼 代碼如下:

function SanitizeFileName( $sNewFileName ){
 global $Config ;
 $sNewFileName = stripslashes( $sNewFileName ) ;
 if ( $Config['ForceSingleExtension'] )
  $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
 //獲得擴(kuò)展名
 $sExtension = substr( $sNewFileName, ( strrpos($sNewFileName, '.') + 1 ) ) ;
 $sExtension = strtolower( $sExtension ) ;
 $sNewFileName =  date("YmdHis").'.'.$sExtension;
 return $sNewFileName ;
}

現(xiàn)在上傳的文件就會(huì)自動(dòng)被重命名了。

相關(guān)文章

最新評(píng)論