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 in the form of a date-based directoryFor example, if today is July 22, all files uploaded today are stored in this directory. files uploaded tomorrow are automatically created and stored in directories similar to May 5, 2015.
(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 ').'/';
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.