admin管理员组文章数量:1124020
we have a multisite installation with following configuration:
bash-5.0# cat /usr/local/etc/php/conf.d/uploads.ini
file_uploads = On
memory_limit = 500M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 600
max_file_uploads = 50000
max_execution_time = 5000
max_input_time = 5000
Our /usr/local/etc/php/php.ini
has:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
;
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
;
upload_max_filesize = 2M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
but on the wp-admin
panel we see this:
How an we fix this? None of the existing answers helped here. we checked functions.php
file. It does not have any ini_set
calls in it.
Running phpinfo
we have observed:
Loaded Configuration File => /usr/local/etc/php/php.ini
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
...
/usr/local/etc/php/conf.d/uploads.ini
post_max_size => 100M => 100M
upload_max_filesize => 100M => 100M
/
in
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
/**
* Filters the maximum upload size allowed in php.ini.
*
* @since 2.5.0
*
* @param int $size Max upload size limit in bytes.
* @param int $u_bytes Maximum upload filesize in bytes.
* @param int $p_bytes Maximum size of POST data in bytes.
*/
return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
}
we have a multisite installation with following configuration:
bash-5.0# cat /usr/local/etc/php/conf.d/uploads.ini
file_uploads = On
memory_limit = 500M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 600
max_file_uploads = 50000
max_execution_time = 5000
max_input_time = 5000
Our /usr/local/etc/php/php.ini
has:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
but on the wp-admin
panel we see this:
How an we fix this? None of the existing answers helped here. we checked functions.php
file. It does not have any ini_set
calls in it.
Running phpinfo
we have observed:
Loaded Configuration File => /usr/local/etc/php/php.ini
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
...
/usr/local/etc/php/conf.d/uploads.ini
post_max_size => 100M => 100M
upload_max_filesize => 100M => 100M
https://developer.wordpress.org/reference/functions/wp_max_upload_size/
in
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
/**
* Filters the maximum upload size allowed in php.ini.
*
* @since 2.5.0
*
* @param int $size Max upload size limit in bytes.
* @param int $u_bytes Maximum upload filesize in bytes.
* @param int $p_bytes Maximum size of POST data in bytes.
*/
return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
}
Share
Improve this question
edited Mar 26, 2024 at 1:36
Jesse Nickles
7357 silver badges19 bronze badges
asked Feb 8, 2021 at 22:59
morpheusmorpheus
1557 bronze badges
1
- Related: stackoverflow.com/questions/20474685/… – Jesse Nickles Commented Mar 13, 2024 at 7:27
1 Answer
Reset to default 2Upon debugging we found the wp_max_upload_size
function was returning 1MB. The u_bytes
and p_bytes
were as expected and equal to 100MB as defined in our uploads.ini
file but the application of upload_size_limit
filter changed the size to 1MB i.e., the problem was at:
return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
A upload_size_limit_filter
is defined in wp-includes/ms-functions.php
and is wired up to execute only for a multisite installation. (the wiring code is in wp-includes/ms-default-filters.php
. The filename has a ms
prefix standing for multisite):
// this function runs only for a multisite installation of wordpress
function upload_size_limit_filter( $size ) {
$fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return min( $size, $fileupload_maxk );
}
return min( $size, $fileupload_maxk, get_upload_space_available() );
}
and tracing the code path we found that fileupload_maxk
equalled 1536000
and so this is what was causing the issue. The fileupload_maxk
value is fetched from MySQL.
Continuing, we could see this in MySQL DB. The wp_sitemeta
table only exists for a multisite installation:
mysql> select * from wp_sitemeta where meta_key = 'fileupload_maxk';
+---------+---------+-----------------+------------+
| meta_id | site_id | meta_key | meta_value |
+---------+---------+-----------------+------------+
| 7 | 1 | fileupload_maxk | 1500 |
+---------+---------+-----------------+------------+
1 row in set (0.00 sec)
and so the fix for this problem is to update this value. It can be done using wp-cli as follows. We are using a multisite installation so have to use wp site
command:
bash-5.0# wp site option update fileupload_maxk 10000 --allow-root
Success: Updated 'fileupload_maxk' site option.
This updates the entry in MySQL and the issue is fixed. In short, it seems that the fileupload_maxk
does not seem to be well known. None of our Google searches on original query led us to it. Here is another answer on SO that talks about fileupload_maxk
.
本文标签:
版权声明:本文标题:Unable to upload files greater than 1MB in size in Multisite network? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736603893a1945279.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论