wp_upload_dir ( $time = null, $create_dir = true, $refresh_cache = false )

  • (string) time Optional. Time formatted in 'yyyy/mm'. Default null.
  • (bool) create_dir Optional. Whether to check and create the uploads directory. Default true for backward compatibility.
  • (bool) refresh_cache Optional. Whether to refresh the cache. Default false.
  • (array) { Array of information about the upload directory. @type string $path Base directory and subdirectory or full path to upload directory. @type string $url Base URL and subdirectory or absolute URL to upload directory. @type string $subdir Subdirectory if uploads use year/month folders option is on. @type string $basedir Path without subdir. @type string $baseurl URL path without subdir. @type string|false $error False or error message. }
Defined at:


Returns an array containing the current upload directory's path and URL.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.

Related Functions

_wp_upload_dir, wp_get_upload_dir, wp_upload_bits, wp_max_upload_size, wp_preload_dialogs

Top Google Results

User discussions

wpseek mobile