How to limit ckeditor upload picture file size _php Tips

Source: Internet
Author: User
Tags file upload
One can modify the php.ini configuration file upload size to limit, another method can only manually modify the FCKeditor source code, the following methods
Open the editor/filemanager/connectors/php directory config.php, create config variable set upload picture size, here in KB
1, $Config [' maximagesize ']= ' 1024 ';
2, open the editor/filemanager/connectors/php directory under commands.php, find
Copy Code code as follows:

if (Isset ($Config [' secureimageuploads '])
{
if ($isImageValid = Isimagevalid ($oFile [' Tmp_name '], $sExtension) = = False)
{
$sErrorNumber = ' 202 ';
}
Upload picture size limit
}
In the upload picture size limit, add
if (Isset ($Config [' maximagesize '])
{
$iFileSize = Round ($oFile [' size ']/1024);
if ($iFileSize > $Config [' maximagesize '])
{
$sErrorNumber = ' 204 ';
}
}

Description: Because the PHP calculation upload image size in bytes, so the code will upload the picture size to KB, and then to compare whether the specified picture size, such as exceeded, the error.
Note that the final
Copy Code code as follows:

if (! $sErrorNumber && isallowedext ($sExtension, $resourceType))
{
FCKeditor Upload Image function
}
Else
$sErrorNumber = ' 202 ';

code block at the end of the Else statement removal, otherwise can not achieve limit fckeditor upload picture file size function.
3, open editor/dialog/fck_image/fck_image.js, add error code (errornumber) information, find the onuploadcompleted function, add
Copy Code code as follows:

Case 204:
Alert ("Security error.") File size error. ") ;
return;

This limit fckeditor upload picture file size configuration is complete, other types of upload file size limit is also this idea.

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.