Returns an array of key => value pairs containing path information on the currently configured uploads directory.

Checks the 'upload_path' option, which should be from the web root folder, and if it isn't empty it will be used. If it is empty, then the path will be 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.

The upload URL path is set either by the 'upload_url_path' option or by using the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.

If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in the administration settings panel), then the time will be used. The format will be year first and then month.

If the path couldn't be created, then an error will be returned with the key 'error' containing the error message. The error suggests that the parent directory is not writable by the server.

On success, the returned array will have many indices:

wp_upload_dir() 描述


wp_upload_dir() 用法



(string) (可选) Time formatted in 'yyyy/mm'.

默认值: null

wp_upload_dir() 参数


添加于 版本: 2.0.0

wp_upload_dir() 历史


wp_upload_dir() 函数的代码位于 wp-includes/functions.php.

wp_upload_dir() 源文件