How to Change the WordPress Media Upload Directory

By  on  

One thing I've always missed about the "old" way of web development was the simplicity of FTP. No deploy scripts, no fuss: simple drag and drop of files and the files are there. I've used FTP for assets on this blog for over a decade but I'm finally ready to be lazy enough to want to drag images into WordPress and use them as WordPress intended.

The problem is that I want the files to upload to custom directory, not the wp-content/uploads directory that WordPress defaults to. The following PHP snippet in the WordPress wp-config.php file allows you to change WordPress' default upload directory:

require_once(ABSPATH.'wp-settings.php');
define('UPLOADS', 'my-demo');

Files uploaded within the WordPress / browser interface will be added in this custom directory. Note that WordPress will create the directory if not present, and will also automatically create and upload the file to a {year}/{month} directory within that custom directory.

I wish I had set this configuration years ago. Having to open a separate app and then write the custom HTML to insert this image has been an inconvenience for a long time!

Recent Features

  • By
    I’m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

  • By
    Vibration API

    Many of the new APIs provided to us by browser vendors are more targeted toward the mobile user than the desktop user.  One of those simple APIs the Vibration API.  The Vibration API allows developers to direct the device, using JavaScript, to vibrate in...

Incredible Demos

  • By
    Printing MooTools Accordion Items

    Sometimes we're presented with unforeseen problems when it comes to our JavaScript effects. In this case, I'm talking about printing jQuery and MooTools accordions. Each "closed" accordion content element has its height set to 0 which means it will be hidden when the...

  • By
    Disable Autocomplete, Autocapitalize, and Autocorrect

    Mobile and desktop browser vendors do their best to help us not look like idiots by providing us autocomplete, autocorrect, and autocapitalize features.  Unfortunately these features can sometimes get in the way;  we don't always want or need the help they provide.  Luckily most browsers allow...

Discussion

  1. shawn caza

    If you don’t want to mess with the config file, you might be able to use wordpress’s secret hidden settings page to do this: https://your-site.com/wp-admin/options.php

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!