PHP ckeditor upload picture file size limit Modify _php tutorial

Source: Internet
Author: User
CKEditor editor when uploading pictures or files is no size limit, let us introduce two ckeditor upload picture file size limit problem resolution.

One can be limited by modifying the php.ini profile upload size, another method can only manually modify the FCKeditor source code, the method is as follows
1, open editor/filemanager/connectors/php directory config.php, create config variable set upload image size, here in kilobytes

1, $Config [' maximagesize ']= ' 1024 ';

2, open the editor/filemanager/connectors/php directory under commands.php, find

The code is as follows Copy Code


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

Note: Since PHP calculates the size of the uploaded image in bytes, the code first converts the uploaded image size to KB, and then compares whether the specified image size is exceeded, if the error is exceeded.
Note that the final

The code is as follows Copy Code
if (! $sErrorNumber && isallowedext ($sExtension, $resourceType))
{
FCKeditor Upload Image function
}
Else
$sErrorNumber = ' 202 ';

The Else statement at the end of the code block is removed, otherwise the ability to limit fckeditor upload image file size is not implemented.

3. Open Editor/dialog/fck_image/fck_image.js, add error code (errornumber) information, find onuploadcompleted function, add

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

To this limit fckeditor upload image file Size configuration is complete, other types of upload file size limit is also this way of thinking.

http://www.bkjia.com/PHPjc/632760.html www.bkjia.com true http://www.bkjia.com/PHPjc/632760.html techarticle CKEditor editor when uploading pictures or files is no size limit, let us introduce two ckeditor upload picture file size limit problem resolution. One can pass ...

  • 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.