CKEditor+CKFinder+php upload file configuration method, the new version of CKEditor only provides basic text editing functions, and the upload module consists of another component, CKFinder. Here we mainly record some parameter configurations uploaded by CKFinder, which can successfully upload files, customize the uploaded file directory, and rename files by date + random characters.
The new version of CKEditor only provides basic text editing functions, and the upload module is provided by another component, CKFinder. Here we mainly record some parameter configurations uploaded by CKFinder, which can successfully upload files, customize the uploaded file directory, and rename files by date + random characters.
1. Download CKFinder.
Download CKFinder, unzip and put it in the same directory as CKEditor, download address: http://ckfinder.com/
2. Enable the upload function.
Open the ckfinder\config.php file, find the function CheckAuthentication(), about line 21, change the last line return false; to return true;
3. Customize the upload file directory.
Open the ckfinder\config.php file and set the variable $baseUrl = '/upload/';, about line 63.
4. Set up the upload subdirectory to be generated by date.
If your website uploads a lot of files and the files are all in one directory, you may not be very concerned about file performance. In this case, we will generate the directory in the format of /upload/yyyy/mm/. Open the ckfinder\config.php file and find $config['ResourceType'][], about line 189, between 'url' => $baseUrl . 'files' and 'directory' => $baseDir . 'files' Add . '/' . date("Y") . '/' . date("m"), as well as other Images and Flash items. The url here represents the address returned to the input box after uploading, and directory represents the directory of the uploaded file.
5. Rename the uploaded file by date + random characters.
This can support file uploads with Chinese names. Open the ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php file and add a generate file name function at the end of the file
The code is as follows
|
Copy code
|
||||||||
$gettime = explode(' ', microtime());
| for ($x = 0; $x < 5; $x++) {
return date("ymdHis") . substr($gettime[0], 2, 6) . $rand;