FCKeditor php Upload File Rename settings _ Web Editor

Source: Internet
Author: User
Tags rand
Here after groping: found a way to rename, we look good to make.
First: I want the uploaded file to organize the folder according to the date
Please modify the: config.php file under the editor\editor\filemanager\connectors\php folder
Find the following:
Path to user files relative to the document root.
$Config [' userfilespath '] =
Modified to:
Path to user files relative to the document root.
$Config [' userfilespath '] = '/uploadfiles/'. Date ("Ym"). " /" ;
The uploaded files are stored according to the date.
Second: renaming
Please modify the io.php file under this folder
Found it:
Do a cleanup of the ' file name to avoid possible problems
function Sanitizefilename ($sNewFileName)
{
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
Replace dots in the name and underscores (only one dot can there ... security issue).
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\\. [^.] *$)/', ' _ ', $sNewFileName);
Remove \/| : ? * "< >
$sNewFileName = Preg_replace ('/\\\\|\\/|\\| | \\:|\\?| \\*|"| <|>/', ' _ ', $sNewFileName);
return $sNewFileName;
}
Modified to:
Do a cleanup of the ' file name to avoid possible problems
function Sanitizefilename ($sNewFileName)
{
Global $Config;
$sNewFileName = Stripslashes ($sNewFileName);
Replace dots in the name and underscores (only one dot can there ... security issue).
if ($Config [' forcesingleextension '])
$sNewFileName = Preg_replace ('/\\. [^.] *$)/', ' _ ', $sNewFileName);
$sExtension = substr ($sNewFileName, (Strrpos ($sNewFileName, '. ') + 1));
$sNewFileName = My_setfilename (). $sExtension;
return $sNewFileName;
}
function My_setfilename () {
$gettime = Explode (', microtime ());
$string = ' abcdefghijklmnopgrstuvwxyz0123456789 ';
$rand = ';
For ($x =0 $x <12; $x + +)
$rand. = substr ($string, Mt_rand (0,strlen ($string)-1), 1);
Return date ("Ymdhis"). substr ($gettime [0],2,6). $rand;
}
This will enable you to rename the uploaded file.

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.