Home > Backend Development > PHP Tutorial > How to store and rename files uploaded by fckeditor by date, upload files by fckeditor_PHP tutorial

How to store and rename files uploaded by fckeditor by date, upload files by fckeditor_PHP tutorial

WBOY
Release: 2016-07-13 09:53:10
Original
1031 people have browsed it

How to store and rename files uploaded by fckeditor by date, upload files by fckeditor

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 a directory similar to 2015-05-06.

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

(2) Find the following configuration variables

View code print
Copy code The code is as follows:
$Config['UserFilesPath'] = '/uploadfiles/';

Change its value to:

View code print
Copy code The code is as follows:
$Config['UserFilesPath'] = '/uploadfiles/'.date('Y-m-d').'/';

The uploaded files are stored according to date.

2. How to rename files uploaded by fckeditor

(1) Find the editoreditorfilemanagerconnectorsphpio.php file:

(2) Find the following content:
Copy code 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 ;
}
......

was changed to:
Copy code 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 ;
}

Uploaded files will now be automatically renamed.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1003991.htmlTechArticleHow to store and rename files uploaded by fckeditor by date, upload files by fckeditor 1. Implement fckeditor's format of dividing directories by date Store uploaded files, for example, today is May 5, 2015...
Related labels:
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