How to save and rename files uploaded by fckeditor by date. Fckeditor Upload file storage by date and rename the Upload file method 1. implement fckeditor to store uploaded files by date. for example, if today is July 22, May 5, 2015, then fckeditor uploads files by date for storage and rename the file upload method.
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:
$Config['UserFilesPath'] = '/uploadfiles/';
Modify the value:
$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:
......function SanitizeFileName( $sNewFileName ){global $Config ;$sNewFileName = stripslashes( $sNewFileName ) ;if ( $Config['ForceSingleExtension'] )$sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;$sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>/', '_', $sNewFileName );return $sNewFileName ;}......
To:
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.
Articles you may be interested in
- PHP is the safest and most practical solution to determine the type of uploaded files
- Use SecureCRT to upload and download files (using sz and rz commands)
- How to align check boxes (checkbox) and single-digit (radio) horizontally and vertically with the text
- Add vcastr3 Video Player plug-in to FCKeditor
- Linux chmod (file or folder permission setting) command parameters and usage details
- Js restrictions: only English letters and numbers can be entered. Chinese characters and other special characters cannot be entered.
- JavaScript and Jquery dynamically load Js files and Css files
- Js to determine whether an array contains repeated values
Example 1. implement fckeditor to store uploaded files in the form of a date-based directory. for example, if today is July 22, May 5, 2015, then...