How to Change the Upload Directory in WordPress

Posted on Updated on

When you add new videos and images to WordPress, they are stored in a default “uploads” folder with a certain URL structure consisting of month and year based folder organization. If you go to “Settings -> Media” in the latest versions of WordPress, you can see the checkbox allowing you to configure this option.

month year organization

However before WordPress 3.8, it also allowed you to select the directory in which you wanted WordPress to upload the media files. They removed it because it wasn’t being used much and also because accidentally changing the file upload folder can have disastrous consequences for your blog media!

But there are often valid reasons to make this change. Some people prefer to host their media content in a subdomain or perhaps just to add a little bit of obscurity to the normally predictable WordPress URLs so that it makes it more difficult for people to access your uploads folder willy-nilly. For these reasons, WordPress still allows us to define the location of the uploads folder relative to the blog path, but we need to specify it in the wp-config.php file instead. Here’s how.

Changing the Upload Location

The default location of our media files is “wp-content/uploads” where “wp-content” is located in the root of your WordPress installation. You can see in the screenshot below that images I’ve already uploaded have this kind of directory structure:

default uploads folder

In this example, I’m going to move the folder out of wp-content and into the WordPress root. We can modify this if we want and simply change the directory name of “uploads” to something else as well. Open up your WordPress installation location via FTP and in the root directory of the application, right-click and modify the wp-config.php file like this:

As you scroll down the contents of wp-config.php, you see a number of “define” statements which specify the values of certain variables in capital letters. Underneath one of these on a new separate line, paste in the following:

define( 'UPLOADS', 'files' );

This defines a variable called “UPLOADS”. The value is relative to the blog root directory. So when we assign it the value “files”, it means the folder called “files” is in the main WordPress folder, sharing the same level with others like “wp-content” and “wp-includes”. Replace this with whatever directory you want to put your media in. If for example, you simply want to rename the “uploads” folder, use this code instead:

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

This effectively changes the name of “uploads” to “files”. Note how there’s no starting slash – an important thing to remember. Once you save the changes to wp-config.php, reload your “Media” folder. You should see something like this:

now uploads location

As expected, all your existing media uploads are broken since they’re still pointing to the old location.


p style=”text-align: center;”>existing files broken

To fix this, you have to copy or move everything in the old folder to the new one, while maintaining the same directory structure.

Also, you’re probably going to have to change the URLs of all linked images from your blog posts. Its’ easier to do that with a plugin that directly manipulates the database. You can see how to do that with my earlier tutorial here. From now on whenever you insert new media into WordPress, it will assign it to the new upload location as shown here:

Changing your media upload location might help you achieve the URL consistency you’re looking for and also may allow you to take advantage of some pagespeed benefits from sub-domains. However it’s not a smart security tactic by itself, though it can serve some specific purposes.

Read WordPress Hosting Reviews

One Reply to “How to Change the Upload Directory in WordPress”!

  • I noticed you mentioned it’s not a great security choice to change folder info to get rid of that wp-content in url. What are the security issues? How can it make me vulnerable any more than where they are if not blocked via htaccess? Though I have htaccess blocking my content, I was wondering though and got more worried after your mention.

    I’m not sure what to do. Because personally I think it looks highly unprofessional for any site to have wp anywhere in the links/urls that may be indexed. What are your suggestions to keep security while looking more professional. The last thing I want is people to know my business site is run on WP. I wish WP would consider that business have the same reasoning as I do. It great in some ways but i think it was started and still maintained for people that didn’t code. Like back in the days when people bought a flash template and had no money to pay developer if they couldn’t code at all.

    Will await your security tip on this one..

Leave a Reply

Your email address will not be published. Required fields are marked *