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.