限制ckeditor上传图片文件大小的方法_PHP
FCKEditor
一种可以通过修改PHP.INI配置文件上传大小来限制,另一种方法只能手动修改Fckeditor源码,方法如下打开editor/filemanager/connectors/php目录下config.php,创建Config变量设置上传图片大小,这里以KB为单位
1、$Config['MaxImageSize']= '1024';
2、打开editor/filemanager/connectors/php目录下commands.php,找到
复制代码 代码如下:
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';
}
}
说明:由于PHP计算上传图片大小以字节为单位,所以代码首先将上传的图片大小折算为KB,再来对比是否超出了规定的图片大小,如超出,则报错。
注意最后将
复制代码 代码如下:
if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) )
{
//Fckeditor上传图片功能
}
else
$sErrorNumber = '202' ;
代码块结尾处的else语句去除,否则实现不了限制Fckeditor上传图片文件大小的功能。
3、打开editor/dialog/fck_image/fck_image.js,添加错误代码(errorNumber)信息,找到OnUploadCompleted函数,添加
复制代码 代码如下:
case 204 :
alert( "Security error. File size error." ) ;
return ;
至此限制Fckeditor上传图片文件大小配置就完成了,其他类型的上传文件大小限制也是这种思路。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











With the widespread use of web applications, creating rich text editors has become more and more common. CKEditor is widely recognized as one of the best rich text editors because of its good customizability and ease of use. This article will introduce how to create a rich text editor using PHP and CKEditor. Introduction to CKEditor CKEditor is an open source, cross-platform rich text editor implemented through JavaScript. It provides an intuitive and easy-to-understand toolbar, including font style, formatting, graphics, etc.

The size of a file is the amount of storage space that a specific file takes up on a specific storage device, such as a hard drive. The size of a file is measured in bytes. In this section, we will discuss how to implement a java program to get the size of a given file in bytes, kilobytes and megabytes. A byte is the smallest unit of digital information. One byte equals eight bits. One kilobyte (KB) = 1,024 bytes, one megabyte (MB) = 1,024KB, one gigabyte (GB) = 1,024MB and one terabyte (TB) = 1,024GB. The size of a file usually depends on the type of file and the amount of data it contains. Taking a text document as an example, the file size may be only a few kilobytes, while a high-resolution image or video file may be

Question: How to get file size in C++? Answer: 1. Use the std::ifstream::tellg() member function to get the number of bytes read or written since opening the file stream; 2. Use std::filesystem::directory_iterator to traverse the files in the directory, and Use std::ifstream::tellg() to calculate the number of bytes in each file and add them up to get the total size.

PHP Image Operation: How to Get the Size and File Size of Images In developing websites or applications, we often need to process images. Obtaining the size and file size of images is a common requirement, which can be easily achieved through some functions in PHP. This article will introduce how to use PHP to obtain the size and file size of images, and attach a code example. Get the image size To get the image size, you can use PHP's built-in function getimagesize(). This function will return a file containing the image size

PHP is a server-side scripting language widely used in web development and is designed to provide support for the creation of dynamic web pages. One of the commonly used operations is to get the file size. File size is important to web developers as they need to ensure that the content of their website is not too large to impact the user experience. In PHP, you can use the filesize() function to get the file size. The syntax of this function is as follows: filesize(string$filename):float

As one of the most popular short video sharing platforms in the world, Douyin has attracted hundreds of millions of users to join it. When looking at other people's wonderful works, we are often moved by some dynamic, interesting or meaningful moments in them. At this time, we can not only express our opinions and thoughts through text comments, but also express our emotions more vividly through picture comments. So, how to post picture comments on TikTok? First, open the Douyin APP and enter the video you are interested in. Next, we need to determine the operating system of the mobile phone according to the different

How to determine the file size of compressed packages through PHPZipArchive? Summary: PHP's ZipArchive class is a very useful tool that can be used to create, modify and extract compressed archives. However, sometimes we may need to judge the file size in the compressed package so that we can be prepared when dealing with large files. In this article, we will learn how to determine the size of the files in the compressed package through PHP's ZipArchive class. Steps: First, we need to create a Z

How to upload pictures with ueditor and add watermark? The following article will introduce to you how to use ueditor to upload pictures and add watermarks in PHP. I hope it will be helpful to you!
