Home  >  Article  >  Backend Development  >  How to store and rename files uploaded by fckeditor by date_PHP tutorial

How to store and rename files uploaded by fckeditor by date_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:53:001036browse

How to store and rename files uploaded by fckeditor by date

This article mainly introduces the method of storing and renaming files uploaded by fckeditor by date. This article modifies the relevant PHP files to achieve this Two requirements, friends in need can refer to the following

1. Implement fckeditor to store uploaded files in directories by date. For example, today is May 5, 2015, then the files uploaded today will be placed in this directory, and the files uploaded tomorrow will be automatically created and placed in Go to a directory like 2015-05-06.

(1) Find the config.php file in the editoreditorfilemanagerconnectorsphp folder

(2) Find the following configuration variables

View code printing

The code is as follows:

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

Modify its value to:

View code printing

The code is as follows:

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

The uploaded files will be stored according to date.

 2. How to rename files uploaded by fckeditor

(1) Find the editoreditorfilemanagerconnectorsphpio.php file:

(2) Find the following content:

The code is as follows:

 ……

Function SanitizeFileName( $sNewFileName ){

global $Config ;

 $sNewFileName = stripslashes( $sNewFileName ) ;

 if ( $Config['ForceSingleExtension'] )

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

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

return $sNewFileName ;

 }

 ……

Modified to:

The code is as follows:

Function SanitizeFileName( $sNewFileName ){

global $Config ;

 $sNewFileName = stripslashes( $sNewFileName ) ;

 if ( $Config['ForceSingleExtension'] )

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

//Get extension

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

 $sExtension = strtolower( $sExtension ) ;

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

return $sNewFileName ;

 }

Now the uploaded file will be automatically renamed.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1004547.htmlTechArticleHow to store and rename files uploaded by fckeditor by date. This article mainly introduces how to store and rename files uploaded by fckeditor by date. Naming method, this article modifies the relevant PHP files to implement these two...
Statement:
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