WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I imagine that this would be a breeze for some - but I'm having difficulty getting just the upload's directory name - not the full path - I've gotten this far:

$uploads = wp_upload_dir();
$upload_path = $uploads['baseurl']; // now how to get just the directory name?

anyone have any ideas? thanks for sharing your experience. . .

share|improve this question
basename($uploads['baseurl']) ? – onetrickpony Apr 4 '12 at 13:36
up vote 4 down vote accepted

This is what you get back from the function:

    [path] => C:\development\xampp\htdocs\example.com/content/uploads/2012/04
    [url] => http://example.com/content/uploads/2012/04
    [subdir] => /2012/04
    [basedir] => C:\~\example.com/content/uploads
    [baseurl] => http://example.com/content/uploads
    [error] => 

So you can get the (as @OneTrickPony pointed out), folder/directory name with

echo wp_basename( $uploads['baseurl'] );

If you're running multisite and you defined the constant UPLOADS, then you access it from UPLOADS or BLOGUPLOADDIR.

share|improve this answer
- thanks to both of you there. basename and after some research wp_basename too I'd reckon. – orionrush Apr 4 '12 at 16:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.