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