fckeditor php上傳文件重命名的設(shè)置
更新時(shí)間:2009年04月17日 21:32:26 作者:
我使用的fckeditor版本是fckeditor2.6.4.
fckeditor默認(rèn)上傳文件不沒有重命名的,這樣的話就很麻煩,有時(shí)上傳中文的文件或者名稱重復(fù)的文件就很惱火。
這里經(jīng)過(guò)摸索:找到了一個(gè)重命名的方法,大家看看好不好使。
首先:我希望上傳的文件根據(jù)日期來(lái)組織文件夾
請(qǐng)修改editor\editor\filemanager\connectors\php文件夾下的:config.php文件
找到如下的內(nèi)容:
// 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")."/" ;
這樣上傳的文件就按照日期存放了。
其次:重命名
請(qǐng)修改該文件夾下的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;
}
這樣上傳的文件就可以實(shí)現(xiàn)重命名了。
首先:我希望上傳的文件根據(jù)日期來(lái)組織文件夾
請(qǐng)修改editor\editor\filemanager\connectors\php文件夾下的:config.php文件
找到如下的內(nèi)容:
// 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")."/" ;
這樣上傳的文件就按照日期存放了。
其次:重命名
請(qǐng)修改該文件夾下的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;
}
這樣上傳的文件就可以實(shí)現(xiàn)重命名了。
您可能感興趣的文章:
- PHP自動(dòng)重命名文件實(shí)現(xiàn)方法
- php 隨機(jī)數(shù)的產(chǎn)生、頁(yè)面跳轉(zhuǎn)、件讀寫、文件重命名、switch語(yǔ)句
- 6種php上傳圖片重命名的方法實(shí)例
- 基于php上傳圖片重命名的6種解決方法的詳細(xì)介紹
- PHP批量修改文件名稱的方法分析
- php實(shí)現(xiàn)批量修改文件名稱的方法
- PHP實(shí)現(xiàn)批量修改文件后綴名的方法
- php實(shí)現(xiàn)文件編碼批量轉(zhuǎn)換
- php中批量修改文件后綴名的函數(shù)代碼
- php中批量替換文件名的實(shí)現(xiàn)代碼
- PHP實(shí)現(xiàn)批量重命名某個(gè)文件夾下所有文件的方法
相關(guān)文章
javascript fckeditor編輯器取值與賦值實(shí)現(xiàn)代碼
這篇文章對(duì)于使用fckeditor編輯器的朋友是個(gè)不錯(cuò)應(yīng)用,主要介紹的是js對(duì)fckeditor的取值與賦值操作,fckeditor是個(gè)不錯(cuò)的比較方便的擴(kuò)展功能的編輯器。2010-05-05FCKeditor 2.6.6在ASP中的安裝及配置方法分享
FCKeditor目前的最新版本是2.6.6,在網(wǎng)上搜索此版本的配置方法,發(fā)現(xiàn)很少有asp的配置方法,以下就把自己的一些配置經(jīng)驗(yàn)分享給有需要的你。2012-03-03使用ZeroClipboard解決跨瀏覽器復(fù)制到剪貼板的問(wèn)題
Zero Clipboard 利用透明的Flash讓其漂浮在復(fù)制按鈕之上,這樣其實(shí)點(diǎn)擊的不是按鈕而是 Flash ,這樣將需要的內(nèi)容傳入Flash,再通過(guò)Flash的復(fù)制功能把傳入的內(nèi)容復(fù)制到剪貼板2014-06-06將CKfinder 整合進(jìn) CKEditor3.0的方法
CKFinder是一款基于AJAX的文件瀏覽器,這是ASP.NET專用版,它可以在線瀏覽文件、管理文件、上傳文件,以樹形Tree的方式展開目錄,自動(dòng)檢測(cè)圖片并生成縮略圖,它是由Fckeditor公司出品,同時(shí)也可配合FckEditor來(lái)使用,可達(dá)到意想不到的效果。2010-01-01解決SyntaxHighlighter 代碼高亮不換行問(wèn)題的解決方法
用SyntaxHighlighter 語(yǔ)法高亮插件的朋友可能都遇到過(guò)代碼顯示不換行的問(wèn)題,這個(gè)問(wèn)題在網(wǎng)上也找不到什么解決辦法,一直困擾了我很久,今天算是把它解決了,辦法其實(shí)簡(jiǎn)單,下面說(shuō)下如何解決2014-11-11快速解決百度編譯器json報(bào)錯(cuò)的問(wèn)題
下面小編就為大家?guī)?lái)一篇快速解決百度編譯器json報(bào)錯(cuò)的問(wèn)題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-08-08新浪博客在線編輯器傻瓜調(diào)用版(2007.11.1第四次修正)提供下載了
新浪博客在線編輯器傻瓜調(diào)用版(2007.11.1第四次修正)提供下載了...2007-11-11eWebEditor_v280_Free_Final最好用的網(wǎng)頁(yè)編輯器下載
eWebEditor_v280_Free_Final最好用的網(wǎng)頁(yè)編輯器下載...2007-09-09