I always use:
ABSPATH . "wp-content/uploads/"
but if anyone knows of a WP command to get the path I would be very interested also…
Or get_bloginfo('wpurl')."/wp-content/upolads/" if you don’t want the absolute path (for a hyperlink or whatever)…
Use:
$upload_dir = wp_upload_dir();
$upload_dir is now an array containing:
$upload_dir['path'] : Server directory path.
$upload_dir['url'] : URL to upload directory.
Excellent info… Thanks muchly Kafkaesqui!!
Forgot to note this is a *dynamic* value, in that if one is organizing uploads under month/year-based directories, it returns the *current* upload directory. So $upload_dir['url'] would return something like:
http://my-site/wp-content/uploads/2006/02
today, but will change next month. For those organizing your upload attachments this way, here’s how you can grab just the top level upload dir while still using wp_upload_dir():
$upload_dir = wp_upload_dir();
$upload_path_base = preg_replace('|/([0-9]{1,4})/([0-9]{1,2})|', '', $upload_dir['path']);
$upload_url_base = preg_replace('|/([0-9]{1,4})/([0-9]{1,2})|', '', $upload_dir['url']);