How to store and rename files uploaded by fckeditor by date
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