Sep
2
2016

Changing the default uploads directory in WordPress

By default, all media – images, files, etc – uploaded in to a WordPress website in the wp-content/uploads directory.

There are times that this isn’t particularly helpful – for example, if you want to maintain legacy URLs for images from an old website you have migrated to WordPress, you’ll need to change the value.  This is our brief guide for changing the default uploads directory in WordPress.

WordPress 3.4 and under allowed you to change the file uploads path in the WordPress administration screen under the Settings panel, but this feature was removed in WordPress 3.5 and above.

WordPress’ default media uploads directory

By default, files uploaded via WordPress’ “insert media” tool (see screenshot below, as it appears in WordPress 4.6.x onwards) are saved on the server in the wp-content/uploads directory, sorted in to sub-directories ordered by year and month.

For example, if you upload a file called image.jpg to WordPress in September 2016, by default this file would be written to the wp-content/uploads/2016/09 directory on the server.

As mentioned above, this may not be ideal for your WordPress website, and this default can be changed.

Changing WordPress default uploads directory

Thankfully, changing WordPress’ default file uploads directory is relatively simple, once you know how.

Open your WordPress installation’s wp-config.php file, found in the root directory of your website. Find the following declaration (if it exists in your wp-config.php file), or add this line to the bottom of your file if it doesn’t exist:

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

The above change would save uploaded files in WordPress’ wp-content/media directory. If you want to move the file uploads to the root directory of the website (e.g., so your files are accessible via http://www.example.com/uploads/), use the following snippet in your wp-config.php file:

define('UPLOADS', 'uploads');

Note! You will need to ensure this directory has the correct permissions for WordPress to be able to use the new file uploads path you have just set. It’s also worth ensuring that final semi-colon – ; – is present at the end of the line, as missing this will likely cause you some issues!

Disabling WordPress from storing uploaded files by year and date

Of course, you can also disable WordPress’ default behaviour of organising file uploads in to year/month directories in the Settings > Media page.

We hope this post is helpful for WordPress users and developers alike! If you need further help with your website, please do consider our WordPress consultancy services.