This article mainly introduces how to store and rename files uploaded by fckeditor by date. This article modifies the related PHP files to meet these two requirements. For more information, see
This article mainly introduces how to store and rename files uploaded by fckeditor by date. This article modifies the related PHP files to meet these two requirements. For more information, see
1. implement fckeditor to store uploaded files by date. For example, if today is July 22, May 5, 2015, all files uploaded today are stored in this directory, tomorrow, the uploaded files will be automatically created and placed in a directory similar.
(1) Find the config. php file in the editor \ filemanager \ connectors \ php \ folder.
(2) Find the following configuration variables:
View code printing
The Code is as follows:
$ Config ['userfilespath'] = '/uploadfiles /';
Modify the value:
View code printing
The Code is as follows:
$ Config ['userfilespath'] = '/uploadfiles/'. date ('Y-m-d'). 'HTTP: // www.jb51.net /';
In this way, the uploaded files are stored by date.
2. How to rename the File Uploaded By fckeditor
(1) Find the editor \ filemanager \ connectors \ php \ io. 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;
}
......
To:
The Code is as follows:
Function SanitizeFileName ($ sNewFileName ){
Global $ Config;
$ SNewFileName = stripslashes ($ sNewFileName );
If ($ Config ['forcesingleextension'])
$ SNewFileName = preg_replace ('/\\.(?! [^.] * $)/',' _ ', $ SNewFileName );
// Obtain the extension
$ SExtension = substr ($ sNewFileName, (strrpos ($ sNewFileName, '.') + 1 ));
$ SExtension = strtolower ($ sExtension );
$ SNewFileName = date ("YmdHis"). '.'. $ sExtension;
Return $ sNewFileName;
}
Now the uploaded file will be automatically renamed.