The ckeditor editor has no size limit when uploading images or files. Below we will introduce to you two solutions to the problem of file size limit for uploading images in ckeditor.
One method can be limited by modifying the upload size of the PHP.INI configuration file. The other method can only manually modify the Fckeditor source code. The method is as follows
1. Open config.php in the editor/filemanager/connectors/php directory, create a Config variable to set the upload image size, here the unit is KB
1. $Config['MaxImageSize']= '1024';
2. Open commands.php in the editor/filemanager/connectors/php directory and find
The code is as follows
代码如下 |
复制代码 |
if ( isset( $Config['SecureImageUploads'] ) )
{
if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false )
{
$sErrorNumber = '202' ;
}
//上传图片大小限制
}
在上传图片大小限制处,添加
if ( isset( $Config['MaxImageSize'] ) )
{
$iFileSize = round( $oFile['size'] / 1024 );
if($iFileSize > $Config['MaxImageSize'] )
{
$sErrorNumber = '204';
}
}
|
|
Copy code
|
if ( isset( $Config['SecureImageUploads'] ) )
代码如下 |
复制代码 |
if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) )
{
//Fckeditor上传图片功能
}
else
$sErrorNumber = '202' ; |
{
if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false )
{
$sErrorNumber = '202' ;
}
代码如下 |
复制代码 |
case 204 :
alert( "Security error. File size error." ) ;
return ; |
//Upload image size limit
}
In the upload image size limit, add |
if ( isset( $Config['MaxImageSize'] ) )
{
$iFileSize = round( $oFile['size'] / 1024 );
if($iFileSize > $Config['MaxImageSize'] )
{
$sErrorNumber = '204';
}
}
Note: Since PHP calculates the uploaded image size in bytes, the code first converts the uploaded image size into KB, and then compares whether it exceeds the specified image size. If it exceeds, an error will be reported.
Note that the last word will be
The code is as follows
|
Copy code
|
if ( !$sErrorNumber && IsAllowedExt( $sExtension , $resourceType ) )
{
//Fckeditor upload picture function
else
$sErrorNumber = '202' ;
Remove the else statement at the end of the code block, otherwise the function of limiting the size of image files uploaded by Fckeditor cannot be implemented.
3. Open editor/dialog/fck_image/fck_image.js, add error code (errorNumber) information, find the OnUploadCompleted function, and add
The code is as follows
|
Copy code
|
case 204 :
alert( "Security error. File size error." ) ;
return ;
At this point, the configuration of limiting the size of uploaded image files by Fckeditor is completed. The same idea is used to limit the size of other types of uploaded files.
http://www.bkjia.com/PHPjc/632760.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632760.htmlTechArticleThe ckeditor editor has no size limit when uploading images or files. Let’s introduce two kinds of ckeditor to you. Solution to upload image file size limit issue. One can pass...
|
|