Get Uploads Directory Path in WordPress

April 21, 2017

The following function can be used to get the absolute path to the WordPress uploads directory:

* Get the absolute path to the WordPress uploads directory,
* with a trailing slash.
* @return string The uploads directory path.
function km_get_wordpress_uploads_directory_path() {
$upload_dir = wp_upload_dir();
return trailingslashit( $upload_dir['basedir'] );

It will return a path to where the WordPress /uploads/ directory is, whether it’s in the default location or whether an UPLOADS constant has been defined to specify an alternate location. The path it returns will look something like:


Kellen Mace

Written by Kellen Mace, who lives in Rochester Hills, MI and builds cool stuff on the web. About Kellen // Follow him on Twitter →