wp_get_upload_dir()

Retrieves uploads directory information.


Description Description

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.

See also See also


Top ↑

Return Return

(array) See wp_upload_dir() for description.


Top ↑

Source Source

File: wp-includes/functions.php

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

Top ↑

Changelog Changelog

Changelog
Version Description
4.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Đăng Tú

    Sample result of the function

    If it is called in index.php:

    array(6) {
    	["path"]=> string(61) "server/wp-content/uploads/2019/07"
    	["url"]=> string(46)
    	"https://example.com/wp-content/uploads/2019/07"
    	["subdir"]=> string(8) "/2019/07"
    	["basedir"]=> string(53) "server/wp-content/uploads"
    	["baseurl"]=> string(38) "https://example.com/wp-content/uploads"
    	["error"]=> bool(false)
    }
    

You must log in before being able to contribute a note or feedback.