fckeditor上传文件按日期存放及重命名方法_PHP教程

WBOY
Release: 2016-07-13 09:53:00
Original
946 people have browsed it

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

   这篇文章主要介绍了fckeditor上传文件按日期存放及重命名方法,本文修改了相关PHP文件实现这二个需求,需要的朋友可以参考下

  1. 实现 fckeditor 按日期分目录的形式存放上传的文件,比如今天是 2015年5月5日,那么今天上传的文件都放在这个目录里面去,明天上传的则自动创建并放在类似 2015-05-06 这样的目录里面去。

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

  (2)找到如下配置变量

  查看代码打印

   代码如下:

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

  将其值修改为:

  查看代码打印

   代码如下:

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

  这样上传的文件就按照日期存放了。

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

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

  (2)找到如下内容:

   代码如下:

  ......

  function SanitizeFileName( $sNewFileName ){

  global $Config ;

  $sNewFileName = stripslashes( $sNewFileName ) ;

  if ( $Config['ForceSingleExtension'] )

  $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;

  $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|/', '_', $sNewFileName );

  return $sNewFileName ;

  }

  ......

  修改为:

  代码如下:

  function SanitizeFileName( $sNewFileName ){

  global $Config ;

  $sNewFileName = stripslashes( $sNewFileName ) ;

  if ( $Config['ForceSingleExtension'] )

  $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;

  //获得扩展名

  $sExtension = substr( $sNewFileName, ( strrpos($sNewFileName, '.') + 1 ) ) ;

  $sExtension = strtolower( $sExtension ) ;

  $sNewFileName = date("YmdHis").'.'.$sExtension;

  return $sNewFileName ;

  }

  现在上传的文件就会自动被重命名了。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1004547.htmlTechArticlefckeditor上传文件按日期存放及重命名方法 这篇文章主要介绍了fckeditor上传文件按日期存放及重命名方法,本文修改了相关PHP文件实现这二个...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!