Modify the size limit of the image file uploaded by php ckeditor

Source: Internet
Author: User
Tags error code

One method can be used to limit the size of the PHP. INI configuration file to be uploaded. The other method can only be used to manually modify the Fckeditor source code. The method is as follows:
1. Open config. php in the editor/filemanager/connectors/php directory, and create a Config variable to set the size of the uploaded image. In KB
 
1. $ Config ['maximagesize'] = '000000 ';

2. Open commands. php in the editor/filemanager/connectors/php directory and find

The code is as follows: Copy code


If (isset ($ Config ['secureimageupload'])
{
If ($ isImageValid = IsImageValid ($ oFile ['tmp _ name'], $ sExtension) === false)
{
$ SErrorNumber = '123 ';
}
// Size limit of uploaded images
}
Add
If (isset ($ Config ['maximagesize'])
{
$ IFileSize = round ($ oFile ['size']/1024 );
If ($ iFileSize> $ Config ['maximagesize'])
{
$ SErrorNumber = '123 ';
}
}

Note: Because PHP calculates the size of the uploaded image in bytes, the code first converts the size of the uploaded image to KB, and then compares whether the size of the uploaded image exceeds the specified size, an error is returned.
Note that
 

The code is as follows: Copy code
If (! $ SErrorNumber & IsAllowedExt ($ sExtension, $ resourceType ))
{
// Fckeditor uploads images
}
Else
$ SErrorNumber = '123 ';

Remove the else statement at the end of the code block. Otherwise, the Fckeditor cannot limit the size of the image file to be uploaded.

3. Open editor/dialog/fck_image/fck_image.js, add the error code (errorNumber), find the OnUploadCompleted function, and add

The code is as follows: Copy code
Case 204:
Alert ("Security error. File size error .");
Return;

So far, the Fckeditor can be configured to limit the size of image files to be uploaded. This is also the idea of limiting the size of other types of uploaded files.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.