


How to rename and add watermark to uploaded files in ckeditor_PHP tutorial
This article will introduce to you the configuration of renaming and adding watermarks to upload files using ckeditor. Students who need to know more can refer to it.
First: I want the uploaded files to be organized into folders based on date
Please modify the config.php file in the editoreditorfilemanagerconnectorsphp folder
The following content was found:
The code is as follows | Copy code | ||||||||
$Config['UserFilesPath'] =
|
was changed to:
The code is as follows | Copy code |
// Path to user files relative to the document root. $Config['UserFilesPath'] = '/uploadfiles/'.date("Ym")."/" ; |
The uploaded files will be stored according to date.
代码如下 | 复制代码 |
// Do a cleanup of the file name to avoid possible problems function SanitizeFileName( $sNewFileName ) { global $Config ; $sNewFileName = stripslashes( $sNewFileName ) ; // Replace dots in the name with underscores (only one dot can be there... security issue). if ( $Config['ForceSingleExtension'] ) $sNewFileName = preg_replace( '/.(?![^.]*$)/', '_', $sNewFileName ) ; // Remove / | : ? * " < > $sNewFileName = preg_replace( '/\|/|||:|?|*|"|<|>/', '_', $sNewFileName ); return $sNewFileName ; } |
Please modify the io.php file in this folder
代码如下 | 复制代码 |
// Do a cleanup of the file name to avoid possible problems function SanitizeFileName( $sNewFileName ) { global $Config ; $sNewFileName = stripslashes( $sNewFileName ) ; // Replace dots in the name with underscores (only one dot can be 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; }
|
The code is as follows | Copy code |
// Do a cleanup of the file name to avoid possible problems function SanitizeFileName( $sNewFileName ) { global $Config ; $sNewFileName = stripslashes( $sNewFileName ) ; // Replace dots in the name with underscores (only one dot can be there... security issue). if ( $Config['ForceSingleExtension'] ) $sNewFileName = preg_replace( '/.(?![^.]*$)/', '_', $sNewFileName ) ; // Remove / | : ? * " < > $sNewFileName = preg_replace( '/\|/|||:|?|*|"|<|>/', '_', $sNewFileName ); return $sNewFileName ; } |
The code is as follows | Copy code |
// Do a cleanup of the file name to avoid possible problems function SanitizeFileName( $sNewFileName ) { global $Config ; $sNewFileName = stripslashes( $sNewFileName ) ; // Replace dots in the name with underscores (only one dot can be 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; } |
Fckeditor upload image file name duplicate name and Chinese garbled solution
After testing, Fckeditor 2.6.6 did not solve the problem of the Chinese name of the uploaded file becoming garbled. This is because Fckeditor did not rename the file when implementing the upload function, which easily led to the problem of duplicate names and garbled characters for uploaded image files.
The solution to uploading image files with duplicate names and garbled characters is as follows
Open commands.php in the editor/filemanager/connectors/php directory, find the FileUpload function, in
The code is as follows | Copy code | ||||
$sExtension = strtolower( $sExtension ) ; Add after $sFileName = rand(0,100).".".$sExtension; |
The rand function here can change the renaming rules as needed.
Another solution to the garbled file name of the uploaded image is to use the iconv function to convert the file name, but there is still a problem of duplicate names, so it is best to rename the file name of the uploaded image to Fckeditor.
Fckeditor uploads pictures to add watermark function
It is essential for website owners to protect the copyright of images and add watermarks. We can use the PHP watermark function combined with the Fckeditor file upload function FileUpload to implement the image watermark function. For watermark functions, please refer to the PHP image watermark function: Supports the use of images and Add watermark to an article in text mode.
The code is as follows | Copy code |
function setWater($imgSrc,$markImg,$markText,$TextColor,$markPos,$fontType,$markType) $srcInfo = @getimagesize($imgSrc); |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Tomato Novel is a very popular novel reading software. We often have new novels and comics to read in Tomato Novel. Every novel and comic is very interesting. Many friends also want to write novels. Earn pocket money and edit the content of the novel you want to write into text. So how do we write the novel in it? My friends don’t know, so let’s go to this site together. Let’s take some time to look at an introduction to how to write a novel. Share the Tomato novel tutorial on how to write a novel. 1. First open the Tomato free novel app on your mobile phone and click on Personal Center - Writer Center. 2. Jump to the Tomato Writer Assistant page - click on Create a new book at the end of the novel.

Unfortunately, people often delete certain contacts accidentally for some reasons. WeChat is a widely used social software. To help users solve this problem, this article will introduce how to retrieve deleted contacts in a simple way. 1. Understand the WeChat contact deletion mechanism. This provides us with the possibility to retrieve deleted contacts. The contact deletion mechanism in WeChat removes them from the address book, but does not delete them completely. 2. Use WeChat’s built-in “Contact Book Recovery” function. WeChat provides “Contact Book Recovery” to save time and energy. Users can quickly retrieve previously deleted contacts through this function. 3. Enter the WeChat settings page and click the lower right corner, open the WeChat application "Me" and click the settings icon in the upper right corner to enter the settings page.

1. We use WPS to open a document. There is a watermark in it. It looks messy. How to remove it? Look down. 2. Find the Insert tab in the menu bar, select the header and footer icons under this tab, and click on them with the left mouse button. 3. At this time, the text on the page becomes gray and cannot be edited, but the watermark on the back of the text can be edited at this time. 4. Click on the watermark, you can see that this is a picture watermark, because there are several small squares around the picture, and the picture can be edited at this time. 5. Use the delete key on the keyboard to delete the picture, and you can see that the watermark is gone. 6. Double-click the mouse on the page to exit the header and footer editing mode. The text on the page returns to normal color and can be edited, but at this time the watermark on the page has disappeared. 7.

How to remove the evaluation copy text in the lower right corner of win1124H2? When we use the system, sometimes the desktop will display a transparent watermark on the lower right corner of the screen. So how do we remove this transparent watermark? Users can directly use third-party software to operate. Let this site carefully introduce to users how to remove the watermark on the win1124H2 evaluation copy. To remove the watermark on the win1124H2 evaluation copy, download the UniversalWatermarkDisabler tool. After running it, the current system version and watermark status will be displayed. If "Ready for installation" is displayed in "Status", it can be removed.

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual
