ckeditor上传文件重命名并加水印配置技巧
发布时间:2022-07-18 13:59:22 所属栏目:PHP教程 来源:互联网
导读:首先:我希望上传的文件根据日期来组织文件夹,请修改editoreditorfilemanagerconnectorsphp文件夹下的config.php文件,找到如下的内容: //Path to user files relative to the document root. $Config[UserFilesPath] = 修改为: //Path to user files relati
首先:我希望上传的文件根据日期来组织文件夹,请修改editoreditorfilemanagerconnectorsphp文件夹下的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). 修改为如下代码: // 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; } Fckeditor上传图片文件名重名及中文乱码解决方法 经测试Fckeditor2.6.6并没有解决上传文件中文名变为乱码的问题,这是由于Fckeditor实现上传功能时并没有将文件重命名,容易导致上传图片文件重名及乱码问题。 上传图片文件重名和乱码解决方法如下 打开editor/filemanager/connectors/php目录下commands.php,找到FileUpload函数,在 $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; 另一种上传图片文件名乱码解决方法为使用iconv函数对文件名进行编码转换,但仍然存在重名问题,所以针对Fckeditor上传图片文件名最好还是重命名。 (编辑:云计算网_泰州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |