FCKeditor uploading files by date and renaming methods _php instances

Source: Internet
Author: User
1. Implement FCKeditor to store uploaded files in the form of a date catalog, such as today is May 5, 2015, then the files uploaded today are placed in this directory, and tomorrow uploaded automatically created and placed in a directory like 2015-05-06.

(1) Locate the config.php file under the Editor\editor\filemanager\connectors\php\ folder

(2) Find the following configuration variables

View Code Printing
Copy the Code code as follows:
$Config [' userfilespath '] = '/uploadfiles/';

Modify its value to:

View Code Printing
Copy the Code code as follows:
$Config [' userfilespath '] = '/uploadfiles/'. Date (' y-m-d '). ' /';

So the uploaded files are stored by date.

2. How to rename FCKeditor uploaded files

(1) Locate editor\editor\filemanager\connectors\php\io.php file:

(2) Find the following:
Copy the Code code as follows:
......
function Sanitizefilename ($sNewFileName) {
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\\. [^.] *$)/', ' _ ', $sNewFileName);
$sNewFileName = Preg_replace ('/\\\\|\\/|\\| | \\:|\\?| \\*|"| <|>/', ' _ ', $sNewFileName);
return $sNewFileName;
}
......

Modified to:
Copy the Code code as follows:
function Sanitizefilename ($sNewFileName) {
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\\. [^.] *$)/', ' _ ', $sNewFileName);
Get extension
$sExtension = substr ($sNewFileName, (Strrpos ($sNewFileName, '. ') + 1));
$sExtension = Strtolower ($sExtension);
$sNewFileName = Date ("Ymdhis"). '. '. $sExtension;
return $sNewFileName;
}

Now the uploaded file is automatically renamed.

  • 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.