Restrict the size of image files uploaded by ckeditor. One way is to modify PHP. INI configuration file upload size limit, another method can only manually modify the Fckeditor source code, the method is as follows to open the editorfilemanagerconnectorsphp directory co can be modified by PHP. INI configuration file upload size limit, another method can only manually modify the Fckeditor source code, the method is as follows
Open config. php in the editor/filemanager/connectors/php directory and create a Config variable to set the size of the uploaded image. the unit is KB.
1. $ Config ['maximagesize'] = '000000 ';
2. open commands. php in the editor/filemanager/connectors/php directory and find
The code is as follows:
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:
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:
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.
Open co in the editor/filemanager/connectors/php directory...