Title: WordPress Max Upload Bug
Last modified: July 23, 2021

---

# WordPress Max Upload Bug

 *  [d1imt](https://wordpress.org/support/users/d1imt/)
 * (@d1imt)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/)
 * Hello all,
    I am running the latest version of WordPress on PHP8 as a multisite
   installation. I noticed on all of the file upload boxes, the max number of bytes
   was displaying as 0 bytes. The PHP max_upload_size and max_post_body size were
   both set to 64M. I traced the ‘upload_size_limit’ filter back to the wp_max_upload_size
   function and think there is an error in its return value;
 *     ```
       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*/ );
       }
       ```
   
 * Since the upload_size_limit_filter function in ms-functions.php only accepts 
   $size as an arg, I don’t think $u_bytes and $p_bytes should be passed. When I
   commented those out as above, everything worked fine.
    -  This topic was modified 4 years, 10 months ago by [d1imt](https://wordpress.org/support/users/d1imt/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Anton Vlasenko](https://wordpress.org/support/users/antonvlasenko/)
 * (@antonvlasenko)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/#post-14695023)
 * I don’t quite get what you mean by
 * > I don’t think $u_bytes and $p_bytes should be passed.
 * It only passes either $u_bytes or $p_bytes, depending on which variable has the
   lowest value.
    And you wrote
 * > The PHP max_upload_size and max_post_body size were both set to 64M.
 * But wp_max_upload_size function reads upload_max_filesize and post_max_size ini
   values, no the values you mentioned. Is it a typo?
    -  This reply was modified 4 years, 10 months ago by [Anton Vlasenko](https://wordpress.org/support/users/antonvlasenko/).
 *  Thread Starter [d1imt](https://wordpress.org/support/users/d1imt/)
 * (@d1imt)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/#post-14695060)
 * [@antonvlasenko](https://wordpress.org/support/users/antonvlasenko/) The call
   to apply_filters inside the function body of wp_max_upload_size passes 3 arguments(
   i.e. min( $u_bytes, $p_bytes ), $u_bytes, and $p_bytes). The receiving function,
   upload_size_limit_filter() in ms-functions.php, only accepts a single argument
   of $size. I believe passing the last 2 arguments $u_bytes and $p_bytes to the
   apply_filters function is redundant and actually causing an error to be returned
   on that line which evaluates to 0. That is why when I commented those two arguments
   out, everything worked as expected.
 *  [Andrew Ozz](https://wordpress.org/support/users/azaozz/)
 * (@azaozz)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/#post-14695148)
 * > I believe passing the last 2 arguments $u_bytes and $p_bytes to the apply_filters
   > function is redundant
 * These are optional args passed to the filter’s callback function when requested.
   See the 4th param of `add_filter()`: [https://developer.wordpress.org/reference/functions/add_filter/](https://developer.wordpress.org/reference/functions/add_filter/).
 * Can you check what’s reported for `upload_max_filesize` and `post_max_size` by`
   phpinfo()` on your server, and compare that to the `$u_bytes` and `$p_bytes` 
   values.
 *  Thread Starter [d1imt](https://wordpress.org/support/users/d1imt/)
 * (@d1imt)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/#post-14695563)
 * [@azaozz](https://wordpress.org/support/users/azaozz/) For both upload_max_filesize
   and post_max_size the value is reported as “64M” in phpinfo.
 * Edit:
    I did a little further digging and the line that adds the filter is in
   ms-default-filters.php.
 *     ```
       L99: add_filter( 'upload_size_limit', 'upload_size_limit_filter' );
       ```
   
 * The default number of args when the 4th parameter isn’t specified is 1. The MS
   filter thus is only registering 1 argument, which is what the upload_size_limit_filter
   accepts. The apply_filter line cited above in media.php is passing an unexpected
   number of arguments.
    -  This reply was modified 4 years, 10 months ago by [d1imt](https://wordpress.org/support/users/d1imt/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WordPress Max Upload Bug’ is closed to new replies.

## Tags

 * [file upload](https://wordpress.org/support/topic-tag/file-upload/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [d1imt](https://wordpress.org/support/users/d1imt/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/wordpress-max-upload-bug/#post-14695563)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
