# Root's "Change default upload location from wp-content/uploads" not working

**URL:** https://discourse.roots.io/t/roots-change-default-upload-location-from-wp-content-uploads-not-working/165
**Category:** uncategorized
**Created:** 2013-08-25T02:18:35Z
**Posts:** 33

## Post 1 by @anon73570552 — 2013-08-25T02:18:35Z

Hi everyone,

Root’s action to change the default media upload location from wp-content/uploads to media does not work.

When uploading media, it uploads to the /media folder as it should but it does not link to it correctly. The images appear with just the border, blank white space and a broken image symbol image in the middle. The thumbnails are also broken like this.

Any ideas?

Thank you

\*\*

## UPDATE: Thanks to @lautreamont this problem was SOLVED! The solution was changing the directory permissions on my “media” folder to 755. Thank you lautreamont!

\*\*

---

## Post 2 by @howdous — 2013-08-25T07:20:15Z

This will help for single and multisite to give you a better understanding - [http://codex.wordpress.org/Function\_Reference/wp\_upload\_dir](http://codex.wordpress.org/Function_Reference/wp_upload_dir)

---

## Post 3 by @anon73570552 — 2013-08-25T07:51:47Z

Thank you for the response but I have already been to this page and I’m not sure how it can help me fix the problem.

The files are getting uploaded to the right location but there seems to be a problem with roots pointing to that right location. I’m not sure where roots is doing this, why it’s doing it or how to fix it.

[mysite.com/public\_html/media/Capture322-150x123.jpg](http://mysite.com/public_html/media/Capture322-150x123.jpg)  
leads to a wordpress “Not Found” page even though that’s the path to the file.

---

## Post 4 by @howdous — 2013-08-25T08:42:16Z

I am also having the same issue in the latest branch of Roots now.

I am currently having a look at /lib/activation.php at around line 189 to see if I can find a solution. I remember now that I had the same issue before with the previous branch and managed to solve it but I can’t remember how.

Let me know if you find anything.

---

## Post 5 by @howdous — 2013-08-25T08:48:57Z

Quite honestly, upon activation of the theme next time I wont opt to let the activation change the media upload location again since it just ends up wasting my time to solve the issue afterwards, twice now.

There is an option upon activation, I don’t know if you have noticed as you activated the theme?

I am however working on a local install with XAMPP and haven’t tried it on a live server yet. Are you also working local?

---

## Post 6 by @Foxaii — 2013-08-25T12:19:05Z

@anon73570552 Can you provide a little background about your server setup? Is it shared hosting?

---

## Post 7 by @anon73570552 — 2013-08-25T18:59:44Z

@Foxaii Dedicated server Centos 5.9 x64  
PHP 5.3.21 / FastCGI  
MySQL 5.1.70  
Latest version of Roots on WP 3.6

@howdous - not working locally. Yes, saw the option upon theme activation. Assuming it’s a problem with roots, should probably fix it or remove the option.

---

## Post 8 by @lautreamont — 2013-08-25T19:10:07Z

I dont think that is roots theme error or wrong doing. Changig upload directorium relativly to wp-content is Wordpress option. Roots just use that option, in my opinion Roots use this idea half-way because it is more usefull to move hole wp-content. That way you may have two directory project with Wordpress stuff in one and user stuff in the other.  
I am not an expert but I check how many .htaccess files I have in project tree and are they different. I mean:

[site\_dir]/.htaccess

[site\_dir]/wp/.htaccess

I sad I am not shure but if thay differ in RewriteBase in my opinion relative addresses wont work.

---

## Post 9 by @Foxaii — 2013-08-25T19:49:42Z

In most cases `public_html` would be the web root, and as such should not actually feature in the url.

My best guess would be there’s a setting on your server, or the WordPress setup itself, that the WordPress code (Roots changes the setting with a WordPress function) does not like.

When you go to change the path, does it show the `public_html` in the path? If so try deleting it.

---

## Post 10 by @anon73570552 — 2013-08-25T20:10:27Z

@Foxaii thank you for the response. If I change the path to _media_ it creates a media folder inside of the public\_html directory. If I change the path to public\_html/media it creates a path that looks like public\_html/public\_html/media

The problem does not appear to be the actual location and uploading of media – that works just fine as it should. The problem appears to be how WordPress is pulling the image after it’s been uploaded.

Example: _[mysite.com/media/anyimage.jpg](http://mysite.com/media/anyimage.jpg)_ will lead to a WordPress theme “Not Found” page even though there is a _/media/anyimage.jpg_ file on the server.

---

## Post 11 by @lautreamont — 2013-08-25T20:35:22Z

Where is instalation of WP.  
Is it in subdirectory or root directroy.  
If in sub did you named it “public\_html”?

---

## Post 12 by @lautreamont — 2013-08-25T20:40:05Z

If you say that every thing is ok with upload do you see images when you in the Media Library?

---

## Post 13 by @anon73570552 — 2013-08-25T20:52:03Z

WP is installed in the root of the website (no subdirectory).

The thumbnail icons in the Media Library are broken, but if I go click “edit” then “edit image” – the image will pop up to edit.

---

## Post 14 by @lautreamont — 2013-08-25T20:56:17Z

Check in Settings-\>Media if:

“Store uploads in this folder” is “media”

and

“Full URL path to files” must be empty.

---

## Post 15 by @anon73570552 — 2013-08-25T21:12:16Z

Already tried that. I tried leaving Full URL path to files empty as well as trying to add the path to the media folder – neither of which worked.

Also, in .htaccess it has this:  
RewriteRule ^assets/(._) /wp-content/themes/mytheme/assets/$1 [QSA,L]  
RewriteRule ^plugins/(._) /wp-content/plugins/$1 [QSA,L]

I tried adding RewriteRule ^media/(.\*) /wp-content/uploads/$1 [QSA,L] but it did not work. The images just still appear as being from wp-content/uploads (so it did nothing).

I’m wondering if there’s somewhere in Roots I need to also define this.

---

## Post 16 by @anon73570552 — 2013-08-25T21:22:28Z

Yeah I’m pretty sure the rewrites are done in lib/rewrites.php but I don’t know PHP very well…

If anyone has any knowledge of it, that would be awesome…

---

## Post 17 by @lautreamont — 2013-08-25T21:44:20Z

You are wrong about rewrites, because, like you see for yourself it only address access to assets and plugins. Changing upload directory is WP option. You can do it without ROOTS on any WP theme from wp-config.php.

Only way that I get on my instalation problem like yours is that I define diferent “relative media directory” and “absolute media directory”. Check your wp-config or plugins that you use.

---

## Post 18 by @anon73570552 — 2013-08-25T21:52:46Z

I understand the re-write does not change the location and that modifying the upload directory within WP itself is possible.

It is not a plugin issue as I have disabled every plugin when testing this. I have tried changing the upload destion in wp-config – it does not work. The images upload fine, to the location, but are not referenced in wordpress posts the way they should:

> Example: [mysite.com/media/anyimage.jpg](http://mysite.com/media/anyimage.jpg) will lead to a WordPress theme  
> “Not Found” page even though there is a /media/anyimage.jpg file on  
> the server.

---

## Post 19 by @anon73570552 — 2013-08-25T22:04:35Z

## **This is what “Roots” does after activation**

![](https://discourse.roots.io/uploads/default/3/388cd6d6517301fc.png)

**This is what happens after I upload a photo (1)**  
- ![](https://discourse.roots.io/uploads/default/4/a23358a3d3e1f7e0.png)

---

## Post 20 by @anon73570552 — 2013-08-25T22:04:46Z

## **And the attachment page:**

![](https://discourse.roots.io/uploads/default/5/f3970d058ddfd5ef.png)

## **And when you go to [mysite.com/media/file.jpg:](http://mysite.com/media/file.jpg:)**

![](https://discourse.roots.io/uploads/default/6/50325455b6239c5f.png)

---

## Post 21 by @lautreamont — 2013-08-25T22:11:00Z

Did you check access rights for media folder and access rights for images, must be owned by www-data:www-data. Sorry, but I have to ask.

---

## Post 22 by @lautreamont — 2013-08-25T22:14:33Z

Put this in templates/single-page.php and open page and postback results,

```
<?php while (have_posts()) : the_post(); ?>
  <?php echo '<p>WP_CONTENT_URL:'.WP_CONTENT_URL.'</p>'; ?>
  <?php echo '<p>WP_CONTENT_DIR:'.WP_CONTENT_DIR.'</p>'; ?>
  <?php echo '<p>UPLOAD_PATH:'.get_option( 'upload_path' ).'</p>'; ?> 
  <?php echo '<p>UPLOAD_URL_PATH:'.get_option( 'upload_url_path' ).'</p>'; ?> 
  <?php the_content(); ?>
  <?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
<?php endwhile; ?>
```

---

## Post 23 by @anon73570552 — 2013-08-25T22:24:48Z

I don’t know what you mean by “must be owned by www-data:www-data” ?

I made a new php file entitled single-page.php, and when accessed it returns:

> Fatal error: Call to undefined function have\_posts() in  
> /home/mysite/public\_html/wp-content/themes/mytheme/templates/single-page.php  
> on line 1

---

## Post 24 by @lautreamont — 2013-08-25T22:43:37Z

I do not know how your os and apache is set up but all files that use by apache must be under his ownership and that is “www-data”. File I send you is original roots file with four lines added, the reason that apache reports error is that when you change/replace it you change/replace ownership on file with yours, and he wont read them.  
I dont know your os, but you must change ownership on all files in your site tree to www-data:www-data and access rights to 775 directories and 644 for files.  
And for the end, you named your site “mysite”, and put WP files in, and what is “public\_html” doing in your directory or is “public\_html” name of your site.

/home/mysite/public\_html/wp-content/themes/mytheme/templates/single-page.php

---

## Post 25 by @anon73570552 — 2013-08-25T22:52:56Z

All of my directory permissions appear to be correct. single-page.php had 644 file permissions when uploading.

/home/ (name of mounted HDD)  
/mysite/ (i censored this, it’s not really “mysite”, and this is the name of the account)  
/public\_html/ (the public\_html directory where all public files go)

---

## Post 26 by @lautreamont — 2013-08-25T23:00:22Z

Where is there your WP instalation, that is question? In what directory?

---

## Post 27 by @anon73570552 — 2013-08-25T23:05:36Z

Root directory. [mysite.com](http://mysite.com) is my wordpress installation.

Also, you were right! I changed permissions of “media” folder to 755 and now it works perfectly :slight_smile:

Thank you!

---

## Post 28 by @lautreamont — 2013-08-25T23:06:40Z

4hr for access rights!

---

## Post 29 by @anon73570552 — 2013-08-25T23:10:22Z

Yes, but with your help, you changed the world. You should be proud of yourself.

---

## Post 30 by @lautreamont — 2013-08-25T23:12:25Z

Ye, I am so happy that is good that I live on seventh floor.

---

## Post 31 by @howdous — 2013-08-26T08:36:34Z

Ha ha that’s why I rather remain on the ground floor - developers has the tendency to jump sometimes when issues like these drives us nuts;-)

---

## Post 32 by @howdous — 2013-08-26T08:59:01Z

I will rather choose not to activate the option in my case since 1) All my sites are multisite and 2) My server runs on NGINX.

---

## Post 33 by @germano — 2014-04-18T22:23:03Z

Check de Folder Permission, set for execute and write public
