How to get max upload size and accepted file types on multisite?

Yes, you can easily grab those multisite values from database using an MU (μ) Function: get_site_option()

Getting Fields

Maximum Upload Size

The maximum upload size, per site (NOT per blog), per file can be found using:

$max_up = get_site_option('fileupload_maxk');
var_dump($max_up); //in kilobytes

Accepted File Types

The accepted file types per site (NOT per blog) can be found using:

$aft = get_site_option('upload_filetypes');
var_dump($aft); //space separated values

//values in an array :)
$aft_array = explode( ' ', $aft );
var_dump($aft);

Under the hood

The values are stored in WordPress multisite database, in sitemeta (can be wp_sitemeta) table, just like any other meta table, using a meta_id, meta_key and meta_value. But as it’s site specific (NOT blog specific), so the site_id is also stored.

Why site_id? Please refer to the #3 link of References.

References:

  1. MU (μ) Functions – WordPress Codex
  2. get_site_option() – WordPress Codex – for additional $keys
  3. WordPress: difference between site_id and blog_id? – StackOverflow

Leave a Comment