Title: wp_get_upload_dir
Published: April 12, 2016
Last modified: February 24, 2026

---

# wp_get_upload_dir(): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#see-also)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#wp--skip-link--target)

Retrieves uploads directory information.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#description)󠁿

Same as [wp_upload_dir()](https://developer.wordpress.org/reference/functions/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](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#see-also)󠁿

 * [wp_upload_dir()](https://developer.wordpress.org/reference/functions/wp_upload_dir/)

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#return)󠁿

 array See [wp_upload_dir()](https://developer.wordpress.org/reference/functions/wp_upload_dir/)
for description.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L2330)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L2330-L2332)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_upload_dir()](https://developer.wordpress.org/reference/functions/wp_upload_dir/)`wp-includes/functions.php` |

Returns an array containing the current upload directory’s path and URL.

  |

| Used by | Description | 
| [WP_Debug_Data::get_sizes()](https://developer.wordpress.org/reference/classes/wp_debug_data/get_sizes/)`wp-admin/includes/class-wp-debug-data.php` |

Fetches the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.

  | 
| [wp_uninitialize_site()](https://developer.wordpress.org/reference/functions/wp_uninitialize_site/)`wp-includes/ms-site.php` |

Runs the uninitialization routine for a given site.

  | 
| [wp_delete_attachment_files()](https://developer.wordpress.org/reference/functions/wp_delete_attachment_files/)`wp-includes/post.php` |

Deletes all files that belong to the given attachment.

  | 
| [wp_calculate_image_srcset()](https://developer.wordpress.org/reference/functions/wp_calculate_image_srcset/)`wp-includes/media.php` |

A helper function to calculate the image sources to include in a ‘srcset’ attribute.

  | 
| [attachment_url_to_postid()](https://developer.wordpress.org/reference/functions/attachment_url_to_postid/)`wp-includes/media.php` |

Tries to convert an attachment URL into a post ID.

  | 
| [wp_unique_filename()](https://developer.wordpress.org/reference/functions/wp_unique_filename/)`wp-includes/functions.php` |

Gets a filename that is sanitized and unique for the given directory.

  | 
| [wp_get_attachment_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_url/)`wp-includes/post.php` |

Retrieves the URL for an attachment.

  | 
| [get_attached_file()](https://developer.wordpress.org/reference/functions/get_attached_file/)`wp-includes/post.php` |

Retrieves attached file path based on attachment ID.

  | 
| [_wp_relative_upload_path()](https://developer.wordpress.org/reference/functions/_wp_relative_upload_path/)`wp-includes/post.php` |

Returns relative path to an uploaded file.

  | 
| [discover_pingback_server_uri()](https://developer.wordpress.org/reference/functions/discover_pingback_server_uri/)`wp-includes/comment.php` |

Finds a pingback server URI based on the given URL.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/?output_format=md#comment-content-3279)
 2.   Anonymous User  [  7 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_upload_dir/#comment-3279)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_upload_dir%2F%23comment-3279)
    Vote results for this note: 7[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_upload_dir%2F%23comment-3279)
 4. **Sample result of the function**
 5. If it is called in `index.php`:
 6.     ```php
        array(6) {
        	["path"] => string(61) "server/wp-content/uploads/2019/07"
        	["url"] => string(46) "https://example.com/wp-content/uploads/2019/07&quot;
        	["subdir"] => string(8) "/2019/07"
        	["basedir"] => string(53) "server/wp-content/uploads"
        	["baseurl"] => string(38) "https://example.com/wp-content/uploads&quot;
        	["error"] => bool(false)
        }
        ```
    
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_upload_dir%2F%3Freplytocom%3D3279%23feedback-editor-3279)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_upload_dir%2F)
before being able to contribute a note or feedback.