How to store and rename files uploaded by fckeditor by date

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.