Fixing /tmp sillyness in WordPress

Something that has annoyed me for quite some time with WordPress is its inability to figure out which temporary path to use when installing new themes and plugins, as well as when you upgrade WordPress itself.

On most servers where I use WordPress, the “global temporary” /tmp is *not* available, and this is a *good* thing. Unfortunately, it causes some problems for WordPress since the default tits-up action is to default to /tmp when all else fails. That in itself isn’t that big of a problem, but IMHO, there’s a more appropriate way of figuring out where to put temporary files: use the configured UPLOAD path. And when I say the “configured UPLOAD path”, I mean the one PHP thinks it should be using.

Why is this a good idea? Well.. a) the system administrator has configured it like it is configured for a reason, b) there’s a fair chance WordPress *can* actually *write* to this directory, and c) it makes WordPress so much more flexible in multi-site environments.

Fortunately, there is a way to get WordPress to habla.

Find and edit your wp-config.php file in the WordPress root. Somewhere (it doesn’t matter where, just as long as you put it inside the , put this line:

define (‘WP_TEMP_DIR’, ini_get (‘upload_tmp_dir’));

Save the file and Bob’s your uncle.

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.