现象描述:
cms内容发布系统上传不了大文件,当上传超过32M文件时就上传不了
提示:无效的文件. 文件尺寸太大。
分析文件上传过程:
browser --> nginx --> php
需要修改 nginx.conf和php.ini
1.nginx.conf新增如下参数,重启无效:
client_max_body_size ???512M;
client_body_buffer_size 128M;
2.修改php.ini配置,重启php-fpm无效:
/usr/local/php-7.0.12_fpm/lib/php.ini
post_max_size = 512M
upload_max_filesize = 256M
3.找到上传文件代码所在的目录 /data/www/cms/cmsx.chinasoft.com.wx/httpdocs/public
[root@newcms:/data/www/cms/cmsx.chinasoft.com.wx/httpdocs/public]# grep -ri "无效的文件. 文件尺寸太大"
resources/js/libs/ckfinder/core/connector/php/lang/zh-cn.php:‘203‘ => ‘无效的文件. 文件尺寸太大。‘,
resources/js/libs/ckfinder/lang/zh-cn.js:203 : ‘无效的文件. 文件尺寸太大。‘,
发现使用了 ckfinder 这个富文本插件
经过搜索发现限制在配置文件config.php,修改最大文件问题解决:
[root@newcms:/data/www/cms/cmsx.chinasoft.com.wx/httpdocs/public]# find ./ -name config.php
/data/www/cms/cmsx.chinasoft.com.wx/httpdocs/public/resources/js/libs/ckfinder/config.php
$config[‘DefaultResourceTypes‘] = ‘‘;
$dir_name_1 = preg_replace(‘/.+\/([^\/]*[a-z]+\.[a-z]+)\/.+/‘, ‘$1‘, $baseDir);
$config[‘ResourceType‘][] = Array(
???????????????‘name‘ => $dir_name_1, ?????????????????????????// Single quotes not allowed
???????????????‘url‘ => $baseUrl,
???????????????‘directory‘ => $baseDir,
???????????????‘maxSize‘ => "300M",# 修改此处
???????????????‘allowedExtensions‘ => isset( $_GET[‘show_format‘] ) ? $_GET[‘show_format‘] : ‘‘,
???????????????‘deniedExtensions‘ => ‘‘);
$config[‘AccessControl‘][] = Array(
???????????????‘role‘ => ‘*‘,
???????????????‘resourceType‘ => $dir_name_1,
???????????????‘folder‘ => ‘/‘,
???????????????‘folderView‘ => true,
???????????????‘folderCreate‘ => true,
???????????????‘folderRename‘ => false,
???????????????‘folderDelete‘ => true,
???????????????‘fileView‘ => true,
???????????????‘fileUpload‘ => true,
???????????????‘fileRename‘ => true,
???????????????‘fileDelete‘ => true);
$dir_name_2 = ‘All files list‘;
$config[‘ResourceType‘][] = Array(
???????????????‘name‘ => $dir_name_2,
???????????????‘url‘ => ‘‘,
???????????????‘directory‘ => ‘‘,
???????????????‘maxSize‘ => "300M", ?# 修改此处
???????????????‘allowedExtensions‘ => isset( $_GET[‘show_format‘] ) ? $_GET[‘show_format‘] : ‘‘,
???????????????‘deniedExtensions‘ => ‘‘);
解决nginx和php使用ckfinder无法上传大文件的问题
原文地址:https://www.cnblogs.com/reblue520/p/10316791.html