# Wp\_upload\_dir() not reporting correct path

**URL:** <https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948>\
**Category:** Community Guides\
**Created:** [December 15, 2022, 9:27pm UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948 "2022-12-15T21:27:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Craig](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/robert_craig/32/1726_2.png) [@Robert\_Craig](https://community.kinsta.com/u/Robert_Craig)\
**Post date:** [December 15, 2022, 9:27pm UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948/1 "2022-12-15T21:27:24Z")

</div>

Has anyone had problems using the wp\_upload\_dir() function. In my install which is on ubuntu it reports as /www/kinsta/public/framerpress/wp-content/uploads/ but is actually /home/robert/DevKinsta/public/framerpress/wp-content/uploads

$uploads = wp\_uploads\_dir();  
error\_log($uploads[‘basedir’]);

So my script is unable to find the files I have in uploads. Is there some other way I should be doing this?

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [December 16, 2022, 3:23am UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948/2 "2022-12-16T03:23:19Z")

</div>

Hello @Robert_Craig 👋 Welcome to DevKinsta community!

I’ve checked the same with this simple PHP script I took from the Internet (and that I modified a bit) - as I’m not a web developer/programmer 😃 and, I then saved that php file under my `/home/myusername/DevKinsta/public/my-site-site/`

```auto
<?php
include( 'wp-load.php' );

$upload_dir = wp_upload_dir(); // Array of key => value pairs
/*
    $upload_dir now contains something like the following (if successful)
    Array (
        [path] => C:\path\to\wordpress\wp-content\uploads\2010\05
        [url] => http://example.com/wp-content/uploads/2010/05
        [subdir] => /2010/05
        [basedir] => C:\path\to\wordpress\wp-content\uploads
        [baseurl] => http://example.com/wp-content/uploads
        [error] =>
    )
    // Descriptions
    [path] - base directory and sub directory or full path to upload directory.
    [url] - base url and sub directory or absolute URL to upload directory.
    [subdir] - sub directory if uploads use year/month folders option is on.
    [basedir] - path without subdir.
    [baseurl] - URL path without subdir.
    [error] - set to false.
*/

echo "Upload dir: <br /><br />";
echo "Path: " . $upload_dir['path'] . '<br />';
echo "URL: " . $upload_dir['url'] . '<br />';
echo "Subdir: " . $upload_dir['subdir'] . '<br />';
echo "Basedir: " .$upload_dir['basedir'] . '<br />';
echo "Baseurl: " . $upload_dir['baseurl'] . '<br />';
echo $upload_dir['error'] . '<br />';

$upload_url = ( $upload_dir['url'] );
$upload_url_alt = ( $upload_dir['baseurl'] . $upload_dir['subdir'] );

// Now echo the final result
echo "Upload URL: " . $upload_url . '<br />'; // Output - http://example.com/wp-content/uploads/2010/05

// Using year and month based folders, the below will be the same as the line above.
echo "Upload URL alt: " . $upload_url_alt . '<br />'; // Output - http://example.com/wp-content/uploads/2010/05
?>

```

and indeed, the “ **basedir** ” from that _**wp\_upload\_dir()**_ function returned with something like (which is expected):

> /www/kinsta/public/site-name/wp-content/uploads

instead of something like this:

> /home/username/DevKinsta/public/site-site/wp-content/uploads

![Screenshot from 2022-12-16 10-20-25](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/8f4c5622561cf9a51ded50b116d62364a6c1ffee.png)

It’s because the **basedir** array value would be returned by the PHP that’s processed in the FPM docker container (the WordPress/site’s php scripts are processed by the PHP inside this FPM docker container) where the particular site’s path is located under that `/www/kinsta/public/site-name/`

You can enter to that docker fpm container via command line (from the Linux terminal) with this command:

> `docker exec -it devkinsta_fpm bash`

 ![Screenshot from 2022-12-16 10-05-30](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/0/0f0e2a71436a7d15e1c80a6b53ce623074dbd7db.png)

In that docker fpm container, if you run the PHP script via CLI ( `php scriptname.php` ) , it would return the same basedir value:

 ![Screenshot from 2022-12-16 10-13-27](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/d/ddad749ef65d3c05f3bb8972e703f4082c91a2fa.png)

Hope this helps/answers to your question and you may want to use that basedir value returned  
(e.g: `/www/kinsta/public/framerpress/wp-content/uploads/` ) in your custom script to make it work correctly/properly 😃 . You may also want to consult with your web developers/programmers if necessary, as we don’t provide support for custom PHP scripts/development related.

Cheers,  
Agus

---

<div class="post-metadata">

**Author:** ![Robert\_Craig](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/robert_craig/32/1726_2.png) [@Robert\_Craig](https://community.kinsta.com/u/Robert_Craig)\
**Post date:** [December 16, 2022, 11:16am UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948/3 "2022-12-16T11:16:01Z")

</div>

Hi thanks for the internals understanding - that makes complete sense. I am the developer 😉 Was able to resolve the issue meantime. Thanks for taking the time to assist 🙂

This thread can definitely be closed now - once again thanks!

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [December 19, 2022, 2:39am UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948/4 "2022-12-19T02:39:23Z")

</div>

Nice! glad to hear that @Robert_Craig👍  
You’re most welcome! 😄  
Alright, I will close this thread now!

---

<div class="post-metadata">

**Author:** ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)\
**Post date:** [December 19, 2022, 2:40am UTC](https://community.kinsta.com/t/wp-upload-dir-not-reporting-correct-path/1948/5 "2022-12-19T02:40:21Z")

</div>


