wp_get_upload_dir()WP 4.5.0

Retrieves uploads directory information.

Same as wp_upload_dir() but "light weight" as it doesn't attempt to create the uploads directory. Intended for use in themes, when only 'basedir' and 'baseurl' are needed, generally in all cases when not uploading files.

1 time — 0.000125 sec (fast) | 50000 times — 0.18 sec (very fast) | PHP 7.0.5, WP 4.5

No Hooks.

Return

Array. See wp_upload_dir() for description.

Usage

wp_get_upload_dir();

Examples

0

#1 Get the download directory data

$dir = wp_get_upload_dir();

print_r( $dir );

/* Will display
Array
(
	[path]    => /home/example.com/public_html/wp-content/uploads/2016/04
	[url]     => http://example.com/wp-content/uploads/2016/04
	[subdir]  => /2016/04
	[basedir] => /home/example.com/public_html/wp-content/uploads
	[baseurl] => http://example.com/wp-content/uploads
	[error]   =>
)
*/

// Display the data
echo $dir['basedir']; // /home/example.com/public_html/wp-content/uploads
echo $dir['baseurl']; // http://example.com/wp-content/uploads
0

#2 Another example of a download folder

See the description of wp_upload_dir().

Notes

Changelog

Since 4.5.0 Introduced.

Code of wp_get_upload_dir() WP 6.0.1

function wp_get_upload_dir() {
	return wp_upload_dir( null, false );
}