How to store and rename files uploaded by fckeditor by date _ PHP Tutorial

Source: Internet
Author: User
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...

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.