Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
2  
basename($uploads['baseurl']) ? –  onetrickpony Apr 4 '12 at 13:36
add comment

1 Answer

up vote 2 down vote accepted

This is what you get back from the function:

Array
(
    [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 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
1  
- thanks to both of you there. basename and after some research wp_basename too I'd reckon. –  orionrush Apr 4 '12 at 16:12
add comment

Your Answer

 
discard

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.