wordpress get uploads directory – wordpress get wp-content directory path

wordpress get uploads directory using $upload_dir = wp_upload_dir(); function. The path it returns will look something like: http://www.domain-name.com/wp-content/uploads

wordpress get uploads directory | file upload to a folder in wordpress

Get Uploads Directory Path in WordPress source code – The following function can be used to get the absolute path to the WordPress uploads directory:

Get Uploads Directory Path In WordPress

The following bellow source code will print the uploads directory path in WordPress Example.

$resDir = wp_upload_dir();
print $resDir['baseurl'];

It will return the path of WordPress upload main base directory like as http://www.pakainfo.com/wp-content/uploads

[path] => /var/www/html/wp-content/uploads/2022/11
[url] => https://www.pakainfo.com/wp-content/uploads/2022/11
[subdir] => /2022/11
[basedir] => /var/www/html/wp-content/uploads
[baseurl] => https://www.pakainfo.com/wp-content/uploads
[error] =>

You can bellow source code this as a function in your main functions.php to wordpress get uploads directory path.

function tp_wordpress_uploads_directory_path() {
	$resDir = wp_upload_dir();
	return $resDir['basedir'];

How to Change the Default Media Upload Location in WordPress?

Changing the Default Media Upload Location in WordPress

define( 'UPLOADS', 'wp-content/'.'files' );
define( 'UPLOADS', ''.'files' );

I hope you get an idea about wordpress get uploads directory.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Also Read This 👉   WooCommerce Get Product Images