Using WordPress ‘ms_upload_constants()’ PHP function

The ms_upload_constants() WordPress PHP function defines Multisite upload constants for backward compatibility with legacy file-serving.

Usage

ms_upload_constants();

Parameters

  • None

More information

See WordPress Developer Resources: ms_upload_constants()
This function exists for backward compatibility with legacy file-serving through wp-includes/ms-files.php (wp-content/blogs.php in MU).

Examples

Defining Multisite Upload Constants

Define the Multisite upload constants in your WordPress Multisite installation.

// Define the Multisite upload constants
ms_upload_constants();

Customizing Multisite Upload Constants

Customize the Multisite upload constants by defining them before calling ms_upload_constants().

// Customize the Multisite upload constants
define('UPLOADBLOGSDIR', 'wp-content/blogs/uploads');

// Define the Multisite upload constants
ms_upload_constants();

Setting Multisite Upload Path

Set the custom upload path for your WordPress Multisite installation.

// Set the custom upload path
define('BLOGUPLOADDIR', '/custom/uploads/path/');

// Define the Multisite upload constants
ms_upload_constants();

Changing Multisite Upload URL

Change the Multisite upload URL to use a custom domain.

// Set the custom upload URL
define('UPLOADS', 'https://customdomain.com/uploads');

// Define the Multisite upload constants
ms_upload_constants();

Setting a Custom Fileupload URL for Multisite

Set a custom fileupload URL for your WordPress Multisite installation.

// Set the custom fileupload URL
define('FILEUPLOAD_URL', 'https://customdomain.com/files');

// Define the Multisite upload constants
ms_upload_constants();